console.log导致内存泄露 打包时自动去掉console.log方法

webpack通过工具:terser

使用前需要先安装一下

vue.config.js

javascript 复制代码
const { defineConfig } = require('@vue/cli-servise');
module.exports = defineConfig({
    transpileDependencies:true,
    terser:{
        terserOptions:{
            compress:{
                drop_console:true,
                drop_debugger:true,
                },
             },
            },
           });

然后直接打包就会自动去掉console.log,不影响开发环境

如果是vue3+vite

vite.config.js

javascript 复制代码
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';

export default defineConfig({
    plugins:[vue()],
    build:{
        minify:'terser',
        terserOptions:{
            compress:{
                drop_console:true,
                drop_debugger:true,
            },
        },
    },
});
相关推荐
杰克尼16 分钟前
vue_day04
前端·javascript·vue.js
明远湖之鱼1 小时前
浅入理解跨端渲染:从零实现 React DSL 跨端渲染机制
前端·react native·react.js
悟忧1 小时前
规避ProseMirror React渲染差异带来的BUG
前端
小皮虾1 小时前
小程序云开发有类似 uniCloud 云对象的方案吗?有的兄弟,有的!
前端·javascript·小程序·云开发
Android疑难杂症2 小时前
鸿蒙Notification Kit通知服务开发快速指南
android·前端·harmonyos
T___T2 小时前
全方位解释 JavaScript 执行机制(从底层到实战)
前端·面试
阳懿2 小时前
meta-llama-3-8B下载失败解决。
前端·javascript·html
Qinana2 小时前
🌊 深入理解 CSS:从选择器到层叠的艺术
前端·css·程序员
IT_陈寒2 小时前
Python 3.12新特性实测:10个让你的代码提速30%的隐藏技巧 🚀
前端·人工智能·后端
闲人编程2 小时前
从零开发一个简单的Web爬虫(使用Requests和BeautifulSoup)
前端·爬虫·beautifulsoup·bs4·web·request·codecapsule