Skip to content

Commit eaaa3c1

Browse files
committedApr 24, 2019
demo
update
1 parent 5dd62ef commit eaaa3c1

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed
 

‎public/index.html

+11
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,22 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
77
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
88
<title><%= webpackConfig.name %></title>
9+
10+
<!-- 引入样式 -->
11+
<% for(var css of htmlWebpackPlugin.options.cdn.css) { %>
12+
<link rel="stylesheet" href="<%=css%>">
13+
<% } %>
914
</head>
1015
<body>
1116
<noscript>
1217
<strong>We're sorry but <%= webpackConfig.name %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
1318
</noscript>
19+
20+
<!-- 引入JS -->
21+
<% for(var js of htmlWebpackPlugin.options.cdn.js) { %>
22+
<script src="<%=js%>"></script>
23+
<% } %>
24+
1425
<div id="app"></div>
1526
<!-- built files will be auto injected -->
1627
</body>

‎src/store/index.js

-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import Vue from 'vue'
21
import Vuex from 'vuex'
32
import getters from './getters'
43
import app from './modules/app'
54
import settings from './modules/settings'
65
import user from './modules/user'
76

8-
Vue.use(Vuex)
9-
107
const store = new Vuex.Store({
118
modules: {
129
app,

‎vue.config.js

+21
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,30 @@ module.exports = {
5151
alias: {
5252
'@': resolve('src')
5353
}
54+
},
55+
externals: {
56+
vue: 'Vue',
57+
'element-ui': 'ELEMENT'
5458
}
5559
},
5660
chainWebpack(config) {
61+
const cdn = {
62+
css: [
63+
// element-ui css
64+
'https://unpkg.com/element-ui/lib/theme-chalk/index.css'
65+
],
66+
js: [
67+
// vue must at first!
68+
'https://unpkg.com/vue/dist/vue.js',
69+
// element-ui js
70+
'https://unpkg.com/element-ui/lib/index.js'
71+
]
72+
}
73+
config.plugin('html')
74+
.tap(args => {
75+
args[0].cdn = cdn
76+
return args
77+
})
5778
config.plugins.delete('preload') // TODO: need test
5879
config.plugins.delete('prefetch') // TODO: need test
5980

2 commit comments

Comments
 (2)

l290347877 commented on Nov 29, 2019

@l290347877

src/main.js 下面的 import 'element-ui/lib/theme-chalk/index.css' 是不是也要去掉,不然还是会打包CSS,以至于加载的时候两个一样的css 都会加载。 不知道我这个改对不对

FlowerHuaer commented on Apr 21, 2021

@FlowerHuaer

打包后报错 Uncaught TypeError: Illegal constructor

Please sign in to comment.