Loading CSS modules
musicbyjing opened this issue · comments
I'm receiving the following error when trying to import css modules:
Module parse failed: Unexpected token
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
In particular, this has happened for Ant Design as well as this progress bar framework. I'm pretty sure Dashbling has css-loader
and style-loader
already in the webpack configuration so I'm not sure what's wrong.
This is because node_modules are excluded in the Webpack config, for performance reasons.
You should be able to make it work by customizing the Webpack config, for example like this:
// dashbling.config.js
module.exports = {
webpackConfig: config => {
config.module.rules = config.module.rules.map(r => {
if(r.test.toString() === /\.s?css$/.toString()) {
delete(r.exclude);
}
return r;
});
return config;
}
};
This removes the exclusion, so Webpack will process (s)css files in node_modules as well.
@musicbyjing I haven't heard back from you so I'm closing the issue. If you have any other questions feel free to reopen!