标签:lse extern zip pre ios lan tps webp https
使用Vue开发的项目在用Webpack打包之后vender和app这两个js文件可能很大,而且有很多的map文件,其体积也不小,那么如何优化打包后体积呢?在webpack.base.conf.js文件中添加打包排除项:
externals: {
‘vue‘: ‘Vue‘,
‘echarts‘: ‘echarts‘,
‘axios‘: ‘axios‘,
‘vuex‘: ‘Vuex‘
},
然后去掉main.js中的导入,在index.html添加BootCDN的链接:
<link href="https://cdn.bootcss.com/element-ui/2.12.0/theme-chalk/index.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/vue/2.6.10/vue.min.js"></script>
<script src="https://cdn.bootcss.com/vuex/3.1.1/vuex.min.js"></script>
<script src="https://cdn.bootcss.com/echarts/4.4.0-rc.1/echarts.min.js"></script>
<script src="https://cdn.bootcss.com/axios/0.19.0/axios.min.js"></script>
在config/index.js中设置:
cssSourceMap: false,
productionSourceMap: false,
productionGzip: true,
component: (resolve) => require([‘../components/Index.vue‘], resolve)
标签:lse extern zip pre ios lan tps webp https
原文地址:https://blog.51cto.com/xvjunjie/2467879