Close source line removal console Vue

1 Introduction

Version 3.0 or greater will not have a problem, based on Vue CLI 3.0 build.

2, the source line Close

Add the following code in Vue.config.js

module.exports = {
    // 关闭线上源码
    productionSourceMap: false,
}

3, remove the console

Plug: Terminal execution

yarn add terser-webpack-plugin

Add the following code in vue.config.js

module.exports = {
    configureWebpack:{
        optimization:{
            minimizer: [new TerserPlugin({ terserOptions: { compress: { drop_console: true } } })]
        }
    }
}

More use of plug-ins, please refer to: terser-WebPACK-plugin

学如逆水行舟,不进则退
Published 498 original articles · won praise 1257 · Views 180,000 +

Guess you like

Origin blog.csdn.net/weixin_42429718/article/details/104221652