Angular-cli: how to ignore class names from minified
Angular cli uses webpack and cleans up internally. One solution would be to change the parameters in uglify by exporting the webpack config. You can see the webpack files by running ng eject and ng eject --prod
new UglifyJsPlugin({
"mangle": false,
"compress": {
"screw_ie8": true,
"warnings": false
},
"sourceMap": false
}),
Mangle = false will keep the class names. The lack of options for webpack in angular cli is one big discussion of atm.
You can change all exceptions like this:
mangle: {
except: ['foozah']
}
Note: after fetching, you can remove the extracted true from angular-cli.json to do it again, or serve / build normally.
"project": {
"name": "test",
"ejected": true //remove
},
source to share
With Andres M's answer, you can turn off mangling without ng eject
directly modifying the Angular file that manages the settings for Webpack:node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/common.js
Please note that this will be overwritten whenever @angular-devkit/build-angular
updated and not supported by Angular or NPM (and could kill your cat / cause nuclear armageddon, don't say I didn't warn you!)
I completely disconnected by changing uglifyOptions
to uglifyOptions: Object.assign(uglifyOptions, {mangle: false})
.
For reference, here's the relevant part from my modified file common.js
...
new UglifyJSPlugin({
sourceMap: buildOptions.sourceMap,
parallel: true,
cache: true,
uglifyOptions: Object.assign(uglifyOptions, {"mangle": false})
}),
...
source to share