Vue3+vite:
npm i terser
// vite.config.js
export default defineConfig(({ mode, command }) => ({
build: {
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
},
}));
Webpack:
npm install terser-webpack-plugin -D
// webpack.config.js
module.exports = {
optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {
drop_console: true,
},
},
}),
],
},
}