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

webpack通过工具:terser

使用前需要先安装一下

vue.config.js

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

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

相关推荐

  1. Handler 导致内存泄露的原因及解决方案

    2024-02-05 06:06:04       48 阅读
  2. 内存泄漏导致Hard_Fault问题记录

    2024-02-05 06:06:04       43 阅读
  3. linux内存泄漏排查方法

    2024-02-05 06:06:04       31 阅读
  4. 记一个闭包导致内存泄漏问题

    2024-02-05 06:06:04       31 阅读
  5. 内存泄露与解决

    2024-02-05 06:06:04       43 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-05 06:06:04       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-05 06:06:04       106 阅读
  3. 在Django里面运行非项目文件

    2024-02-05 06:06:04       87 阅读
  4. Python语言-面向对象

    2024-02-05 06:06:04       96 阅读

热门阅读

  1. flink写入es的参数解析

    2024-02-05 06:06:04       51 阅读
  2. Unity 开发注意事项

    2024-02-05 06:06:04       46 阅读
  3. Elasticsearch的使用场景深入详解

    2024-02-05 06:06:04       49 阅读
  4. Leetcode 3031. Minimum Time to Revert Word to Initial State II

    2024-02-05 06:06:04       50 阅读
  5. JUnit5单元测试框架提供的注解

    2024-02-05 06:06:04       82 阅读
  6. 基础算法bfs -剪枝问题

    2024-02-05 06:06:04       49 阅读
  7. WPF DispatcherTimer用法

    2024-02-05 06:06:04       52 阅读
  8. 常用的正则表达式

    2024-02-05 06:06:04       52 阅读
  9. 力扣:17. 电话号码的字母组合

    2024-02-05 06:06:04       53 阅读
  10. Vivado Tri-MAC IP端口说明

    2024-02-05 06:06:04       60 阅读
  11. Objective-C中的“description“方法

    2024-02-05 06:06:04       50 阅读
  12. Objective-C 中的SEL

    2024-02-05 06:06:04       45 阅读