Skip to content

Commit 0640864

Browse files
committed
优化一下留言板,将element外部引入,不在vendor中添加,页面初次渲染速度明显提升
1 parent cdf6b13 commit 0640864

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

build/webpack.base.conf.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ module.exports = {
2424
entry: {
2525
app: './src/main.js'
2626
},
27+
externals:{
28+
'vue': 'Vue',
29+
'element-ui': 'ELEMENT',
30+
},
2731
output: {
2832
path: config.build.assetsRoot,
2933
filename: '[name].js',

build/webpack.prod.conf.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ const webpackConfig = merge(baseWebpackConfig, {
2929
filename: utils.assetsPath('js/[name].[chunkhash].js'),
3030
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
3131
},
32+
externals:{
33+
'element-ui': 'ELEMENT',
34+
},
3235
plugins: [
3336
// http://vuejs.github.io/vue-loader/en/workflow/production.html
3437
new webpack.DefinePlugin({

index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width,initial-scale=1.0">
66
<title>留言板</title>
7+
<!-- 引入样式 -->
8+
<link rel="stylesheet" href="https://unpkg.com/element-ui@2.0.7/lib/theme-chalk/index.css">
9+
<!-- 引入组件库 -->
10+
711
</head>
812
<body>
13+
<script src="https://unpkg.com/vue@2.5.2/dist/vue.js"></script>
14+
<script src="https://unpkg.com/element-ui@2.0.7/lib/index.js"></script>
915
<div id="app"></div>
1016
<!-- built files will be auto injected -->
1117
</body>

src/main.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import Vue from 'vue'
44
import App from './App'
55
import ElementUI from 'element-ui'
6-
import 'element-ui/lib/theme-chalk/index.css'
7-
import 'element-ui/lib/index.js'
86
import router from './router'
97
import axios from 'axios'
108
import VueAxios from 'vue-axios'

0 commit comments

Comments
 (0)