feat: make the minimizer config available in all modes (#4641)

As long as the `minimize` option is set to false (which is default in
production mode), the code won't be minimized. So the mode doesn't
matter when it comes to the `minimizer` config.

By exposing this config, users can simplify their custom config, by
removing the `process.env.NODE_ENV === 'production'` guard around their
custom minimizer configuration.
This commit is contained in:
Haoqun Jiang
2019-10-07 00:14:28 +08:00
committed by GitHub
parent 3b016e7901
commit f5135d41a5
2 changed files with 6 additions and 6 deletions

View File

@@ -187,5 +187,11 @@ module.exports = (api, options) => {
additionalTransformers: [transformer],
additionalFormatters: [formatter]
}])
const TerserPlugin = require('terser-webpack-plugin')
const terserOptions = require('./terserOptions')
webpackConfig.optimization
.minimizer('terser')
.use(TerserPlugin, [terserOptions(options)])
})
}

View File

@@ -15,12 +15,6 @@ module.exports = (api, options) => {
// disable optimization during tests to speed things up
if (process.env.VUE_CLI_TEST) {
webpackConfig.optimization.minimize(false)
} else {
const TerserPlugin = require('terser-webpack-plugin')
const terserOptions = require('./terserOptions')
webpackConfig.optimization
.minimizer('terser')
.use(TerserPlugin, [terserOptions(options)])
}
}
})