生产环境去掉 console.log
Former-commit-id: 4c5d3837dfb3e9aaebf9075e9a95f77167c48999 [formerly 4c5d3837dfb3e9aaebf9075e9a95f77167c48999 [formerly 4c5d3837dfb3e9aaebf9075e9a95f77167c48999 [formerly 4c5d3837dfb3e9aaebf9075e9a95f77167c48999 [formerly 2b7a8c824c3443a6bda51812e0286410a3a64064 [formerly bbc56136b0bea94202d4aad6904aa3b46b0ff53f]]]]] Former-commit-id: 7e7dbf69361903961a45f4a8f9cfb30662934352 Former-commit-id: 80c8fc47f8d6c8fd47ff86d6ef920b615724f470 Former-commit-id: 5b82f2cb1c11e528b734adfc053f8c859f366d8c [formerly ba28b7db2d41bceaa5c0f69e29cf02d74c7f7944] Former-commit-id: a82f33ce65112adbd09d3e599c809d33235d23be Former-commit-id: 21dff8258e41292f2ea66295cfe10878de9deac1 Former-commit-id: d6bc56570038ff4cd56f26d082ec476f2f9b995d Former-commit-id: 2ffddc58253895c1d7f4564b669326c1f7f6188e Former-commit-id: 42788c9709caba3e5cd7a63542c9a428c8de8acf
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
|
||||||
|
|
||||||
// 拼接路径
|
// 拼接路径
|
||||||
const resolve = dir => require('path').join(__dirname, dir)
|
const resolve = dir => require('path').join(__dirname, dir)
|
||||||
|
|
||||||
@@ -20,9 +22,35 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
// 默认设置: https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-service/lib/config/base.js
|
// 默认设置: https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-service/lib/config/base.js
|
||||||
chainWebpack: config => {
|
chainWebpack: config => {
|
||||||
|
/**
|
||||||
|
* 删除懒加载模块的 prefetch preload,降低带宽压力
|
||||||
|
* https://cli.vuejs.org/zh/guide/html-and-static-assets.html#prefetch
|
||||||
|
* https://cli.vuejs.org/zh/guide/html-and-static-assets.html#preload
|
||||||
|
* 而且预渲染时生成的 prefetch 标签是 modern 版本的,低版本浏览器是不需要的
|
||||||
|
*/
|
||||||
|
config.plugins
|
||||||
|
.delete('prefetch')
|
||||||
|
.delete('preload')
|
||||||
// 解决 cli3 热更新失效 https://github.com/vuejs/vue-cli/issues/1559
|
// 解决 cli3 热更新失效 https://github.com/vuejs/vue-cli/issues/1559
|
||||||
config.resolve
|
config.resolve
|
||||||
.symlinks(true)
|
.symlinks(true)
|
||||||
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
config.optimization
|
||||||
|
// 生产环境移除 console
|
||||||
|
// 其它优化选项 https://segmentfault.com/a/1190000008995453?utm_source=tag-newest#articleHeader12
|
||||||
|
.minimizer([
|
||||||
|
new UglifyJsPlugin({
|
||||||
|
uglifyOptions: {
|
||||||
|
compress: {
|
||||||
|
warnings: false,
|
||||||
|
drop_console: true,
|
||||||
|
drop_debugger: true,
|
||||||
|
pure_funcs: ['console.log']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
])
|
||||||
|
}
|
||||||
// markdown
|
// markdown
|
||||||
config.module
|
config.module
|
||||||
.rule('md')
|
.rule('md')
|
||||||
|
|||||||
Reference in New Issue
Block a user