Then it is configured in the same file a bit further.
I'm using a 3rd party tool that requires setting the uglifyOptions.compress.unused to false.
Since the default is true I have some issues with this library.
My objective is to use extra-webpack.config.js
to modify and add the uglifyOptions compress "unused" to false. Could you give me some guidance on how to get there?
compress: {
pure_getters: buildOptions.buildOptimizer,
// PURE comments work best with 3 passes.
// See https://github.com/webpack/webpack/issues/2899#issuecomment-317425926.
passes: buildOptions.buildOptimizer ? 3 : 1,
// Workaround known uglify-es issue
// See https://github.com/mishoo/UglifyJS2/issues/2949#issuecomment-368070307
inline: wco.supportES2015 ? 1 : 3,
Since this commit they are using TerserPlugin instead of UglifyJsPlugin.
In current implementation you cannot override the instance of a specific plugin inside minimizer array. Plugins merge was implemented for plugins array but not for the rest.
If you'd like this functionality to be added, please open a feature request on github. PR is also welcome.
If you need it now and don't have time to wait for this feature the only option you have is overriding the whole optimization entry.
For this you have to:
Specify optimization: replace in mergeStrategies object in builder configuration
Define all the optimization configuration as it is defined in Angular along with your modifications inside your extra-webpack.config.js.
Angular optimization definitions can be found in
You can do it easily now with version 7.4.1. Just export a function in your config file, it will receive the original config and expected to return a modified config. You can do whatever you like with the config that you receive.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi,
If you see the
node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/common.js
You can see it requests
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
Then it is configured in the same file a bit further.
I'm using a 3rd party tool that requires setting the uglifyOptions.compress.unused to false.
Since the default is true I have some issues with this library.
My objective is to use extra-webpack.config.js
to modify and add the uglifyOptions compress "unused" to false. Could you give me some guidance on how to get there?
unused:false
}
In your plugins section add
UglifyJSPlugin
withcompress.unused
set tofalse
.If
Angular CLI
uses this plugin, your configuration will take preference and will override thecompress.unused
of the defaultUglifyJSPlugin
.@felipecarrillo100 , here are few insights:
TerserPlugin
instead ofUglifyJsPlugin
.minimizer
array. Plugins merge was implemented forplugins
array but not for the rest. If you'd like this functionality to be added, please open a feature request on github. PR is also welcome.optimization
entry. For this you have to:optimization: replace
inmergeStrategies
object in builder configurationextra-webpack.config.js
. Angular optimization definitions can be found inand in
You can do it easily now with version
7.4.1
. Just export a function in your config file, it will receive the original config and expected to return a modified config. You can do whatever you like with the config that you receive.