diff --git a/README.md b/README.md index dcce81f..087f82e 100644 --- a/README.md +++ b/README.md @@ -212,7 +212,7 @@ module.exports = [ path: PATHS.DIST, filename: 'js/[name].js', }, - devtool: (ENV !== 'production') ? 'source-map' : '', + devtool: (ENV !== 'production') ? 'source-map' : false, resolve: resolveJS(ENV, PATHS), externals: externalJS(ENV, PATHS), module: moduleJS(ENV, PATHS), @@ -228,7 +228,7 @@ module.exports = [ output: { path: PATHS.DIST, }, - devtool: (ENV !== 'production') ? 'source-map' : '', + devtool: (ENV !== 'production') ? 'source-map' : false, module: moduleCSS(ENV, PATHS), // Pass the filename here, which will get passed down to MiniCssExtractPlugin plugins: pluginCSS(ENV, PATHS, 'css/[name].css'), diff --git a/configMeta/baseWebpackConfig.js b/configMeta/baseWebpackConfig.js index f4da680..118baf7 100644 --- a/configMeta/baseWebpackConfig.js +++ b/configMeta/baseWebpackConfig.js @@ -53,19 +53,21 @@ module.exports = class BaseWebpackConfig { this.#vendorChunk = vendorChunk; - this.#config.optimization = { - splitChunks: { - cacheGroups: { - vendor: { - name: vendorChunk, - test: test, - reuseExistingChunk: true, - enforce: true, - chunks: 'all', + this.mergeConfig({ + optimization: { + splitChunks: { + cacheGroups: { + vendor: { + name: vendorChunk, + test: test, + reuseExistingChunk: true, + enforce: true, + chunks: 'all', + } } } } - }; + }); // ensure entries are configured to "depend on" the vendor entry if necessary this.#splitVendorFromEntries(); diff --git a/configMeta/cssWebpackConfig.js b/configMeta/cssWebpackConfig.js index c49c7a2..d36e6f3 100644 --- a/configMeta/cssWebpackConfig.js +++ b/configMeta/cssWebpackConfig.js @@ -19,7 +19,7 @@ module.exports = class CssWebpackConfig extends BaseWebpackConfig { output: { path: PATHS.DIST, }, - devtool: (ENV !== 'production') ? 'source-map' : '', + devtool: (ENV !== 'production') ? 'source-map' : false, module: moduleCSS(ENV, PATHS), plugins: pluginCSS(ENV, PATHS, filename), }); diff --git a/configMeta/javascriptWebpackConfig.js b/configMeta/javascriptWebpackConfig.js index 4f837e6..3416c9c 100644 --- a/configMeta/javascriptWebpackConfig.js +++ b/configMeta/javascriptWebpackConfig.js @@ -3,6 +3,7 @@ const externalJS = require('../js/externals'); const moduleJS = require('../js/modules'); const pluginJS = require('../js/plugins'); const resolveJS = require('../js/resolve'); +const TerserPlugin = require('terser-webpack-plugin'); /** * Dynamically generates webpack config for transpiling javascript using Silverstripe default settings @@ -19,11 +20,24 @@ module.exports = class JavascriptWebpackConfig extends BaseWebpackConfig { path: PATHS.DIST, filename: 'js/[name].js', }, - devtool: (ENV !== 'production') ? 'source-map' : '', + devtool: (ENV !== 'production') ? 'source-map' : false, resolve: resolveJS(ENV, PATHS), module: moduleJS(ENV, PATHS), externals: externalJS(ENV, PATHS, moduleName), plugins: pluginJS(ENV), + optimization: { + minimize: true, + minimizer: [ + new TerserPlugin({ + extractComments: false, + terserOptions: { + format: { + comments: false, + }, + }, + }), + ], + }, }); } }