zoukankan      html  css  js  c++  java
  • 减少打包组件vue.config.js——Webpack的externals的使用

    vue.config.js

    module.exports = {
        configureWebpack:{
          externals: {
             vue: 'Vue',
             'vue-router':'VueRouter',
             axios: 'axios'
          }
        }
    }


    在index.html文件中引入CDN

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width,initial-scale=1.0">
        <link rel="icon" href="<%= BASE_URL %>favicon.ico">
        <title></title>
        
        <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.js"></script>
        <script src="https://cdn.bootcss.com/vue-router/3.1.3/vue-router.js"></script>
        <script src="https://cdn.bootcss.com/element-ui/2.12.0/index.js"></script>
        <script src="https://cdn.bootcss.com/element-ui/2.12.0/locale/zh-CN.js"></script>
        <script src="https://cdn.bootcss.com/axios/0.19.0-beta.1/axios.js"></script>
      </head>
      <body>
        <noscript>
          <strong>We're sorry but good doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
        </noscript>
        
    
    
    
        <div id="app"></div>
        <!-- built files will be auto injected -->
      </body>
    </html>

    在index.js文件中删除导入的elementui

    import Vue from 'vue'
    import App from './App.vue'
    import router from './router'
    //import 'element-ui/lib/theme-chalk/index.css'
    //import './plugins/element.js'
    import './assets/global.css'
    Vue.config.productionTip = false
    
    new Vue({
      router,
      render: h => h(App)
    }).$mount('#app')
  • 相关阅读:
    vue的特点
    暴力卸载低版本vuecli
    C#实现汉字转换为拼音缩写的代码
    .net 发送手机短信息
    js 小小jquery等比例缩放图片效果
    Android应用程序运行机制解析
    大型网站的架构设计问题大型高并发高负载网站的系统架构
    《UDP原理》
    《计算机网络中port和socket的作用》
    《线程并发》
  • 原文地址:https://www.cnblogs.com/xbzhu/p/11815197.html
Copyright © 2011-2022 走看看