I'm trying to import CSS as modules to a react app. I have added this to my webpack.config.js file
{
test: /\.css$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader', options: { modules: true } },
],
},
This is the implementation
app.tsx
import styles from './styles.module.css';
class App extends React.Component {
render() {
return (
<div className={styles.mainContent}>
<h1> Hello, World! </h1>
<Button type="primary">Antd works!</Button>
</div>
);
}
}
styles.module.css
.mainContent {
color: limegreen;
}
But this CSS class has no effect on the output.
options: { modules: true }statement? It should work fine as is without that clause.