From 75ff34d285bb0c4a23b01fac7490bf2edf2b24e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=90=8C=E5=AD=A6?= Date: Fri, 19 Oct 2018 16:18:17 +0800 Subject: [PATCH] fix[cssnano]:use official demo of webpack config to avoid temporary bug of build:prod. ps:I have a computer which build:prod well but another computer throw cssnano error. The most amazing thing is that my two computers are same type and project is the same branch. Finally, I add the official config to branch for solving this problem and it works well. --- build/webpack.prod.conf.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/build/webpack.prod.conf.js b/build/webpack.prod.conf.js index 418d5d1d..327d226b 100644 --- a/build/webpack.prod.conf.js +++ b/build/webpack.prod.conf.js @@ -9,7 +9,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin') const HtmlWebpackPlugin = require('html-webpack-plugin') const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin') const MiniCssExtractPlugin = require('mini-css-extract-plugin') -// const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin') +const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin') const UglifyJsPlugin = require('uglifyjs-webpack-plugin') function resolve(dir) { @@ -140,7 +140,15 @@ const webpackConfig = merge(baseWebpackConfig, { }), // Compress extracted CSS. We are using this plugin so that possible // duplicated CSS from different components can be deduped. - // new OptimizeCSSAssetsPlugin() + new OptimizeCSSAssetsPlugin({ + assetNameRegExp: /\.optimize\.css$/g, + cssProcessor: require('cssnano'), + cssProcessorOptions: { + safe: true, + discardComments: { removeAll: true } + }, + canPrint: true + }) ] } })