发布于 1个月前

uniapp 打包上线后看不到 console.log日志,如何开启

打开 vue.config.js,把 drop_consoledrop_debugger改为 false 后,重新打包上线即可看到console.log日志

module.exports = {
    productionSourceMap: false, // 生产打包时不输出map文件,增加打包速度
    configureWebpack: config => {
        if (process.env.NODE_ENV === 'production') {
            config.optimization.minimizer[0].options.terserOptions.compress.warnings = false
            config.optimization.minimizer[0].options.terserOptions.compress.drop_console = false
            config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = false
            config.optimization.minimizer[0].options.terserOptions.compress.pure_funcs = ['console.log']
        }
    }
}
©2020 edoou.com   京ICP备16001874号-3