From 71c932eaf083c951cb534d71768ec8baa27c40b0 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 8 Nov 2018 19:38:45 +0300 Subject: uglifyjs -> terser --- vnext/webpack.config.js | 63 +++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 28 deletions(-) (limited to 'vnext/webpack.config.js') 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; }; -- cgit v1.2.3