Skip to content

Commit e8000dd

Browse files
committed
webpack css config
* use localIdentName also for production build (why not?!) * cleanup webpack rules. they are applied one by one.
1 parent 26e75fb commit e8000dd

File tree

2 files changed

+10
-30
lines changed

2 files changed

+10
-30
lines changed

webpack.common.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,30 +40,29 @@ module.exports = {
4040
test: /\.js$/,
4141
loader: 'source-map-loader',
4242
},
43-
// load styles from node_modules but leave them un-touched
44-
// this is important for codemirror and ol
43+
// We use css modules for our own code, which uses .module.css as naming convention.
4544
{
46-
test: /\.css$/,
47-
include: path.resolve(__dirname, 'node_modules'),
48-
exclude: path.resolve(__dirname, 'src'),
49-
use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],
50-
},
51-
// load styles from sources and apply css modules to them
52-
{
53-
test: /\.css$/,
45+
test: /\.module\.css$/,
5446
exclude: path.resolve(__dirname, 'node_modules'),
5547
use: [
5648
{ loader: 'style-loader' },
5749
{
5850
loader: 'css-loader',
5951
options: {
6052
modules: {
61-
auto: resourcePath => resourcePath.endsWith('.module.css'),
53+
localIdentName: '[path][name]__[local]',
6254
},
6355
},
6456
},
6557
],
6658
},
59+
// All other css files are simply processed without modules.
60+
// We use these for some 3rd party dependencies like ol and codemirror.
61+
{
62+
test: /\.css$/,
63+
exclude: /\.module\.css$/,
64+
use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],
65+
},
6766
// this loader inlines svg images as react components
6867
{
6968
test: /\.svg$/,

webpack.dev.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,6 @@ const develop = {
1212
port: 3000,
1313
host: '0.0.0.0',
1414
},
15-
module: {
16-
rules: [
17-
{
18-
test: /\.css$/,
19-
exclude: path.resolve(__dirname, 'node_modules'),
20-
use: [
21-
{
22-
loader: 'css-loader',
23-
options: {
24-
modules: {
25-
auto: resourcePath => resourcePath.endsWith('.module.css'),
26-
localIdentName: '[path][name]__[local]',
27-
},
28-
},
29-
},
30-
],
31-
},
32-
],
33-
},
3415
}
3516

3617
const mergePattern = {

0 commit comments

Comments
 (0)