Ver código fonte

Merge pull request #284 from xiaopenggithub/master

前端发布优化,部分组件使用cdn资源,不打包
奇淼(piexlmax 4 anos atrás
pai
commit
d0e95dfea9
2 arquivos alterados com 16 adições e 0 exclusões
  1. 5 0
      web/public/index.html
  2. 11 0
      web/vue.config.js

+ 5 - 0
web/public/index.html

@@ -8,6 +8,11 @@
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
     <link rel="icon" href="<%= BASE_URL %>favicon.ico">
     <title>GIN-VUE-ADMIN</title>
+    <% if(process.env.NODE_ENV!=='development'){ %>
+    <script src="//cdn.staticfile.org/vue/2.6.10/vue.min.js"></script>
+    <script src="//cdn.staticfile.org/axios/0.19.0/axios.min.js"></script>
+    <script src="//cdn.staticfile.org/echarts/4.7.0/echarts.min.js"></script>    
+    <% } %>  
 </head>
 
 <body>

+ 11 - 0
web/vue.config.js

@@ -59,6 +59,17 @@ module.exports = {
         config
             .when(process.env.NODE_ENV !== 'development',
                 config => {
+
+                    // 不打包 begin
+                    // 1.目前已经测试通过[vue,axios,echarts]可以cdn引用,其它组件测试通过后可继续添加
+                    // 2.此处添加不打包后,需在public/index.html head中添加相应cdn资源链接
+                    config.set('externals', {
+                        vue: 'Vue',
+                        axios: 'axios',
+                        echarts: 'echarts'
+                    })
+                    // 不打包 end
+
                     config
                         .plugin('ScriptExtHtmlWebpackPlugin')
                         .after('html')