In my React application, I am utilizing CSS modules. By configuring modules:true
in my webpack.config.js
, I can successfully apply styles from files within my src folder. However, when importing components from node-modules, the corresponding CSS is not being applied.
I attempted to import the CSS from node-modules using import 'path';
but it did not yield the desired results.
Interestingly, if I change the configuration to modules:false
, the CSS from node-modules is properly applied while the CSS from src files is neglected.
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [
{
loader: "style-loader"
},
{
loader: "css-loader",
options: {
modules: true,
},
}
],
},
],
},
};