Selaa lähdekoodia

chore: 使用externals数组提取库变量

cuiyalong 4 vuotta sitten
vanhempi
commit
81f0e4aebe
1 muutettua tiedostoa jossa 10 lisäystä ja 13 poistoa
  1. 10 13
      vue.config.js

+ 10 - 13
vue.config.js

@@ -1,15 +1,3 @@
-const externals = {
-  // 把导入语句里的 vue 替换成运行环境(html)里的全局变量 Vue
-  vue: 'Vue',
-  'vue-router': 'VueRouter',
-  vuex: 'Vuex',
-  axios: 'axios',
-  echarts: 'echarts',
-  'v-charts': 'vcharts', // 这个vcharts没有全局变量,是被直接挂载到vue上了
-  'lodash': '_', // lodash在全局变量为_
-  moment: 'moment'
-}
-
 const cdn = {
   css: [
     // '//unpkg.com/element-ui@2.10.1/lib/theme-chalk/index.css'
@@ -75,7 +63,16 @@ module.exports = {
       config.devServer.set('hot', true)
 
       if (process.env.NODE_ENV === 'production') {
-        config.externals(externals)
+        config.externals([
+          'vue',
+          'vue-router',
+          'vuex',
+          'axios',
+          'echarts',
+          'v-charts',
+          'lodash',
+          'moment'
+        ])
         config.plugin('html').tap(args => {
           // html中添加cdn
           args[0].cdn = cdn