美文网首页
打包上线后不输出 console

打包上线后不输出 console

作者: 小石头糖糖 | 来源:发表于2024-02-28 17:44 被阅读0次

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,
          },
        },
      }),
    ],
  },
}

相关文章

网友评论

      本文标题:打包上线后不输出 console

      本文链接:https://www.haomeiwen.com/subject/lslfzdtx.html