Skip to content

Commit 2ac79c3

Browse files
docs: example with CSS modules and pure CSS (#983)
1 parent 967fb66 commit 2ac79c3

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

README.md

+42-1
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ module.exports = {
873873
use: ['style-loader', 'css-loader'],
874874
},
875875
{
876-
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/,
876+
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i,
877877
loader: 'url-loader',
878878
options: {
879879
limit: 8192,
@@ -892,6 +892,47 @@ For production builds it's recommended to extract the CSS from your bundle being
892892

893893
- As an alternative, if seeking better development performance and css outputs that mimic production. [extract-css-chunks-webpack-plugin](https://github.com/faceyspacey/extract-css-chunks-webpack-plugin) offers a hot module reload friendly, extended version of mini-css-extract-plugin. HMR real CSS files in dev, works like mini-css in non-dev
894894

895+
### CSS modules and pure CSS
896+
897+
When you have pure CSS (without CSS modules) and CSS modules in project you can use this setup:
898+
899+
**webpack.config.js**
900+
901+
```js
902+
module.exports = {
903+
module: {
904+
rules: [
905+
{
906+
// For pure CSS (without CSS modules)
907+
test: /\.css$/i,
908+
exclude: /\.module\.css$/i,
909+
use: ['style-loader', 'css-loader'],
910+
},
911+
{
912+
// For CSS modules
913+
test: /\.module\.css$/i,
914+
use: [
915+
'style-loader',
916+
{
917+
loader: 'css-loader',
918+
options: {
919+
modules: true,
920+
},
921+
},
922+
],
923+
},
924+
{
925+
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i,
926+
loader: 'url-loader',
927+
options: {
928+
limit: 8192,
929+
},
930+
},
931+
],
932+
},
933+
};
934+
```
935+
895936
## Contributing
896937

897938
Please take a moment to read our contributing guidelines if you haven't yet done so.

0 commit comments

Comments
 (0)