From b2de1a54a023d545b8433c3942058d430a5ee7fe Mon Sep 17 00:00:00 2001 From: Tony Air Date: Sat, 7 Sep 2019 10:06:25 +0700 Subject: [PATCH] FIX: webpack CSS minifiction --- package.json | 1 + webpack.config.prod.js | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/package.json b/package.json index f1839f2..17f4335 100755 --- a/package.json +++ b/package.json @@ -102,6 +102,7 @@ "uglify-js": "git://github.com/mishoo/UglifyJS2.git#harmony-v2.8.22", "uglifyjs-webpack-plugin": "^2.2.0", "url-loader": "^0.6.2", + "optimize-css-assets-webpack-plugin": "^5.0.3", "webpack": "^4.39.1", "webpack-cli": "^3.3.6", "webpack-dev-server": "^3.8.0", diff --git a/webpack.config.prod.js b/webpack.config.prod.js index 6071d20..9387684 100755 --- a/webpack.config.prod.js +++ b/webpack.config.prod.js @@ -15,6 +15,7 @@ const autoprefixer = require('autoprefixer'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const FaviconsWebpackPlugin = require('favicons-webpack-plugin'); const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); +const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); let plugins = [ new webpack.DefinePlugin({ @@ -52,6 +53,18 @@ let plugins = [ windows: true } }), + new OptimizeCssAssetsPlugin({ + //assetNameRegExp: /\.optimize\.css$/g, + cssProcessor: require('cssnano'), + cssProcessorPluginOptions: { + preset: ['default', { + discardComments: { + removeAll: true + } + }], + }, + canPrint: true + }), ]; // add themes favicons