Skip to content

Commit 81cd1f9

Browse files
Change css-loader output to decrease size of output files (#32)
1 parent 9abff06 commit 81cd1f9

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

webpack.config.demo.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const path = require('path');
22
const StyleLintPlugin = require('stylelint-webpack-plugin');
33
const VisualizerPlugin = require('webpack-visualizer-plugin');
44

5-
module.exports = [{
5+
module.exports = (env, argv) => ({
66
devServer: {
77
contentBase: './demo',
88
disableHostCheck: true,
@@ -31,7 +31,9 @@ module.exports = [{
3131
loader: 'css-loader',
3232
options: {
3333
modules: {
34-
localIdentName: '[name]__[local]__[hash:base64:5]',
34+
localIdentName: argv.mode === 'production'
35+
? '[hash:base64:8]'
36+
: '[name]__[local]__[hash:base64:8]',
3537
},
3638
},
3739
},
@@ -63,4 +65,4 @@ module.exports = [{
6365
extensions: ['.js', '.jsx', '.scss'],
6466
modules: ['src', 'node_modules'],
6567
},
66-
}];
68+
});

webpack.config.lib.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const path = require('path');
22
const StyleLintPlugin = require('stylelint-webpack-plugin');
33
const VisualizerPlugin = require('webpack-visualizer-plugin');
44

5-
module.exports = [{
5+
module.exports = (env, argv) => ({
66
entry: {
77
lib: [
88
path.join(__dirname, 'src/lib/index.js'),
@@ -23,7 +23,9 @@ module.exports = [{
2323
loader: 'css-loader',
2424
options: {
2525
modules: {
26-
localIdentName: '[name]__[local]__[hash:base64:5]',
26+
localIdentName: argv.mode === 'production'
27+
? '[hash:base64:8]'
28+
: '[name]__[local]__[hash:base64:8]',
2729
},
2830
},
2931
},
@@ -52,4 +54,5 @@ module.exports = [{
5254
extensions: ['.js', '.jsx', '.scss'],
5355
modules: ['src/lib', 'node_modules'],
5456
},
55-
}];
57+
});
58+

0 commit comments

Comments
 (0)