diff options
Diffstat (limited to 'vnext/webpack.config.js')
-rw-r--r-- | vnext/webpack.config.js | 63 |
1 files changed, 35 insertions, 28 deletions
diff --git a/vnext/webpack.config.js b/vnext/webpack.config.js index 3748e5db..821070f6 100644 --- a/vnext/webpack.config.js +++ b/vnext/webpack.config.js @@ -2,7 +2,7 @@ const webpack = require('webpack'); const path = require('path'); const HtmlWebPackPlugin = require('html-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); -const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); +const TerserPlugin = require('terser-webpack-plugin'); const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); const ErrorOverlayPlugin = require('error-overlay-webpack-plugin'); @@ -64,12 +64,42 @@ module.exports = (env, argv) => { } ] }, - optimization: { + plugins: [ + new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), + new MiniCssExtractPlugin({ + filename: 'Juick.[contenthash].css', + allChunks: true + }), + new HtmlWebPackPlugin({ + template: './src/views/index.html', + filename: './index.html' + }), + new ErrorOverlayPlugin() + ], + devServer: { + bonjour: true, + historyApiFallback: true, + host: '0.0.0.0', + hot: true, + inline: true + } + }; + + if (dev) { + config.plugins.push(new webpack.HotModuleReplacementPlugin()); + } else { + config.optimization = { minimizer: [ - new UglifyJsPlugin({ + new TerserPlugin({ cache: true, parallel: true, - sourceMap: dev + sourceMap: dev, + terserOptions: { + output: { + comments: /@license/i + } + }, + extractComments: true }), new OptimizeCSSAssetsPlugin({}) ], @@ -94,30 +124,7 @@ module.exports = (env, argv) => { } } } - }, - plugins: [ - new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), - new MiniCssExtractPlugin({ - filename: 'Juick.[contenthash].css', - allChunks: true - }), - new HtmlWebPackPlugin({ - template: './src/views/index.html', - filename: './index.html' - }), - new ErrorOverlayPlugin() - ], - devServer: { - bonjour: true, - historyApiFallback: true, - host: '0.0.0.0', - hot: true, - inline: true - } - }; - - if (dev) { - config.plugins.push(new webpack.HotModuleReplacementPlugin()) + }; } return config; }; |