Reputation: 501
I am building an ionic 4 app and using class names references in the local offline pouch DB it works fine. But when I make the Prod build with optimization true it shortens the classes to single alphabet name -
e extends i.a { constructor(){super(),this.isActive=!0 }}
I have used custom-webpack for keeping the class name with the following code -
module.exports = cfg => {
const options = cfg.optimization.minimizer[cfg.optimization.minimizer.length - 1].options.terserOptions;
if (options) {
options.keep_classnames = true;
}
return cfg;
};
It works fine for ionic serve --configration prod
but not for ionic build --configuration prod
I want to keep class names for ionic build --configration prod
with optimization:true
.
Please help thanks.
Upvotes: 4
Views: 218
Reputation: 35513
You can specify the TerserWebpackPlugin to keep the class names.
module.exports = {
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
keep_classnames: true,
keep_fnames: true,
},
}),
],
},
};
Upvotes: 1