I'm trying to configure my Angular 8 project build to keep functions and classes names (I need my classes names to use reflexion and other class name based stuff).
To manage this, I use @angular-builders/custom-webpack
which allows to override webpack config.
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"customWebpackConfig": {
"path": "./extra-webpack.config.js",
"mergeStrategies": {
"externals": "replace",
}
},
My extra-webpack.config.js
:
console.log('Custom webpack config');
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
keep_classnames: true,
keep_fnames: true,
}
})
]
}
};
As said on the Terser documentation, keep_classnames
is used to keep classes names and keep_fnames
is used to keep functions names.
The problem is that my classes names and my functions names are gone, I cannot find them on the main.XXXX.js build file, and my app doesn't work because the reflexion doesn't works.
I'm sure my extra-webpack.config.js
is not ignored because I can see the "Custom webpack config"
log on my console.
Should I configure something else to keep my functions and classes names?