Skip to content

Commit 50377ef

Browse files
前端发布优化,部分组件使用cdn资源,不打包
1 parent 876ea6a commit 50377ef

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

web/public/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
<meta name="viewport" content="width=device-width,initial-scale=1.0">
88
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
99
<title>GIN-VUE-ADMIN</title>
10+
<% if(process.env.NODE_ENV!=='development'){ %>
11+
<script src="//cdn.staticfile.org/vue/2.6.10/vue.min.js"></script>
12+
<script src="//cdn.staticfile.org/axios/0.19.0/axios.min.js"></script>
13+
<script src="//cdn.staticfile.org/echarts/4.7.0/echarts.min.js"></script>
14+
<% } %>
1015
</head>
1116

1217
<body>

web/vue.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ module.exports = {
5959
config
6060
.when(process.env.NODE_ENV !== 'development',
6161
config => {
62+
63+
// 不打包 begin
64+
// 1.目前已经测试通过[vue,axios,echarts]可以cdn引用,其它组件测试通过后可继续添加
65+
// 2.此处添加不打包后,需在public/index.html head中添加相应cdn资源链接
66+
config.set('externals', {
67+
vue: 'Vue',
68+
axios: 'axios',
69+
echarts: 'echarts'
70+
})
71+
// 不打包 end
72+
6273
config
6374
.plugin('ScriptExtHtmlWebpackPlugin')
6475
.after('html')

0 commit comments

Comments
 (0)