I'm trying to use TerserPlugin to minify my code, I found this snippet below in their official docs:
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
myCustomOption: true,
},
minify: (file, sourceMap, minimizerOptions) => {
const extractedComments = [];
const { map, code } = require("uglify-module").minify(file, {});
return { map, code, extractedComments };
},
}),
],
}
but after adding this snippet I'm getting an error:
Error: Cannot find module 'uglify-module'
also, this 'uglify-module' can't be found on npm registry.
You should use uglify-js
instead of uglify-module