vite 打包 build 去掉console.log

1,281 阅读1分钟

vite 打包 build 去掉console.log

直接上代码:

// vite.config.js

module.exports = {
  build: {
    terserOptions: {
      compress: {
        drop_console: true,
      },
    },
  },
};

请注意,这只会在打包时去掉 console.log,而在开发过程中仍然会保留。