美文网首页
vue项目打包分离element-ui,减小vendor包

vue项目打包分离element-ui,减小vendor包

作者: 隐身的猫 | 来源:发表于2018-07-19 16:26 被阅读0次

第一步:build/webpack.base.conf.js

externals: {

    'vue': 'Vue',

    'element-ui': 'ELEMENT',

  },

第二步:index.html

<script src="https://lib.baomitu.com/vue/2.5.17/vue.min.js"></script>

<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">

<script src="https://unpkg.com/element-ui/lib/index.js"></script>

注意:vue的版本要在2.5以上,测试发现,2.5以下,如果页面有el-table组件,页面会加载不出来

第三步:main.js

去掉main.js里面element-ui的引用

// import './assets/theme/index.css'

// import ElementUI from 'element-ui'

// Vue.use(ElementUI)

相关文章

网友评论

      本文标题:vue项目打包分离element-ui,减小vendor包

      本文链接:https://www.haomeiwen.com/subject/dovtmftx.html