From e3cca78886a677b57a82eb8e6c6265a92713f1be Mon Sep 17 00:00:00 2001 From: getlarge Date: Tue, 9 Mar 2021 07:16:51 +0100 Subject: [PATCH] fix: update webpack config Signed-off-by: getlarge --- plugins/add-vendors-plugin.js | 5 ++-- webpack.development.js | 46 +++++++++++++++++------------------ webpack.parts.js | 2 +- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/plugins/add-vendors-plugin.js b/plugins/add-vendors-plugin.js index 76e4a09..8ed1071 100644 --- a/plugins/add-vendors-plugin.js +++ b/plugins/add-vendors-plugin.js @@ -18,9 +18,9 @@ module.exports = class AddVendorsPlugin { const vendor = compilation.assets[`vendors.${this.base}`] if (main && vendor) { - const compiledAsset = new ConcatSource(main.children[0]) + const compiledAsset = new ConcatSource(main._value[0]) compiledAsset.add(vendor) - compiledAsset.add(main.children[1]) + compiledAsset.add(main._value[1]) compilation.assets = {} compilation.assets[this.base] = compiledAsset } else if (main && mainMap) { @@ -28,6 +28,7 @@ module.exports = class AddVendorsPlugin { compilation.assets[this.base] = main compilation.assets[`${this.base}.map`] = mainMap } + callback() } ) diff --git a/webpack.development.js b/webpack.development.js index 4b2751e..e60bb0b 100644 --- a/webpack.development.js +++ b/webpack.development.js @@ -6,29 +6,29 @@ 'use strict' -const UglifyJsPlugin = require('uglifyjs-webpack-plugin') +const TerserPlugin = require('terser-webpack-plugin') module.exports = { - devtool: 'inline-source-map', - optimization: { - minimizer: [ - new UglifyJsPlugin({ - test: /vendor/, - sourceMap: false, - }), - new UglifyJsPlugin({ - test: /^((?!(vendor)).)*.js$/, - sourceMap: true, - }) - ], - splitChunks: { - cacheGroups: { - commons: { - test: /[\\/]node_modules[\\/]/, - name: 'vendors', - chunks: 'all' - } - } - }, - }, + devtool: 'inline-source-map', + optimization: { + minimizer: [ + new TerserPlugin({ + test: /vendor/, + sourceMap: false + }), + new TerserPlugin({ + test: /^((?!(vendor)).)*.js$/, + sourceMap: false + }) + ], + splitChunks: { + cacheGroups: { + commons: { + test: /[\\/]node_modules[\\/]/, + name: 'vendors', + chunks: 'all' + } + } + } + } } diff --git a/webpack.parts.js b/webpack.parts.js index 7407ee4..bbc8436 100644 --- a/webpack.parts.js +++ b/webpack.parts.js @@ -7,7 +7,7 @@ 'use strict' const path = require('path') -const merge = require('webpack-merge') +const { merge } = require('webpack-merge') const development = require('./webpack.development.js') const production = require('./webpack.production.js')