Skip to content

Commit

Permalink
Change css-loader output to decrease size of output files (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
bedrich-schindler committed Mar 9, 2020
1 parent 9abff06 commit 81cd1f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 5 additions & 3 deletions webpack.config.demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path');
const StyleLintPlugin = require('stylelint-webpack-plugin');
const VisualizerPlugin = require('webpack-visualizer-plugin');

module.exports = [{
module.exports = (env, argv) => ({
devServer: {
contentBase: './demo',
disableHostCheck: true,
Expand Down Expand Up @@ -31,7 +31,9 @@ module.exports = [{
loader: 'css-loader',
options: {
modules: {
localIdentName: '[name]__[local]__[hash:base64:5]',
localIdentName: argv.mode === 'production'
? '[hash:base64:8]'
: '[name]__[local]__[hash:base64:8]',
},
},
},
Expand Down Expand Up @@ -63,4 +65,4 @@ module.exports = [{
extensions: ['.js', '.jsx', '.scss'],
modules: ['src', 'node_modules'],
},
}];
});
9 changes: 6 additions & 3 deletions webpack.config.lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path');
const StyleLintPlugin = require('stylelint-webpack-plugin');
const VisualizerPlugin = require('webpack-visualizer-plugin');

module.exports = [{
module.exports = (env, argv) => ({
entry: {
lib: [
path.join(__dirname, 'src/lib/index.js'),
Expand All @@ -23,7 +23,9 @@ module.exports = [{
loader: 'css-loader',
options: {
modules: {
localIdentName: '[name]__[local]__[hash:base64:5]',
localIdentName: argv.mode === 'production'
? '[hash:base64:8]'
: '[name]__[local]__[hash:base64:8]',
},
},
},
Expand Down Expand Up @@ -52,4 +54,5 @@ module.exports = [{
extensions: ['.js', '.jsx', '.scss'],
modules: ['src/lib', 'node_modules'],
},
}];
});

0 comments on commit 81cd1f9

Please sign in to comment.