Skip to content

Commit 41d9563

Browse files
committed
fix: css bundle
1 parent c91e6be commit 41d9563

File tree

3 files changed

+889
-34
lines changed

3 files changed

+889
-34
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"babel-loader": "^8.1.0",
5252
"clean-webpack-plugin": "^3.0.0",
5353
"css-loader": "^5.1.2",
54+
"css-minimizer-webpack-plugin": "^1.3.0",
5455
"file-loader": "^6.2.0",
5556
"html-webpack-inline-source-plugin": "^0.0.10",
5657
"html-webpack-plugin": "^5.3.1",

webpack.config.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let isProduction = process.env.NODE_ENV === 'production';
99
const getLogger = require('webpack-log');
1010
const log = getLogger({ name: 'webpack-batman' });
1111
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
12-
12+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
1313
log.info(__filename);
1414

1515
// This is main configuration object.
@@ -40,7 +40,7 @@ module.exports = {
4040
// else
4141
// return isProduction ? '[name].min.js' : '[name].js';
4242
// },
43-
43+
chunkFilename: isProduction ? '[name].min.js' : '[name].js',
4444
libraryTarget: 'umd',
4545
libraryExport: 'default',
4646
library: 'CoCreate',
@@ -54,8 +54,8 @@ module.exports = {
5454
new MiniCssExtractPlugin({
5555
// Options similar to the same options in webpackOptions.output
5656
// both options are optional
57-
filename: '[name].css',
58-
chunkFilename: '[id].css',
57+
filename: isProduction ? '[name].min.css' : '[name].css',
58+
chunkFilename: '[name].min.css',
5959
}),
6060
],
6161

@@ -98,21 +98,22 @@ module.exports = {
9898

9999
optimization: {
100100
minimize: true,
101-
// minimizer: [
102-
// new TerserPlugin({
103-
// extractComments: true,
104-
// // cache: true,
105-
// parallel: true,
106-
// // sourceMap: true, // Must be set to true if using source-maps in production
107-
// terserOptions: {
108-
// // https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
109-
// // extractComments: 'all',
110-
// compress: {
111-
// drop_console: true,
112-
// },
113-
// },
114-
// }),
115-
// ],
101+
minimizer: [
102+
new CssMinimizerPlugin(),
103+
new TerserPlugin({
104+
extractComments: true,
105+
// cache: true,
106+
parallel: true,
107+
// sourceMap: true, // Must be set to true if using source-maps in production
108+
terserOptions: {
109+
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
110+
// extractComments: 'all',
111+
compress: {
112+
drop_console: true,
113+
},
114+
},
115+
}),
116+
],
116117
splitChunks: {
117118
chunks: 'all',
118119
minSize: 1,

0 commit comments

Comments
 (0)