Skip to content

Commit 4962657

Browse files
committed
feat: 优化example打包体积
1 parent 7a49a90 commit 4962657

File tree

6 files changed

+70
-4
lines changed

6 files changed

+70
-4
lines changed

example/babel.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ module.exports = {
99
'@babel/plugin-transform-runtime',{
1010
corejs: 3,
1111
}
12+
],
13+
[
14+
"component",
15+
{
16+
"libraryName": "element-ui",
17+
"styleLibraryName": "theme-chalk"
18+
}
1219
]
1320
]
1421
}

example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"@vue/composition-api": "^1.0.0-rc.5",
3333
"autoprefixer": "^10.2.5",
3434
"babel-loader": "^8.2.2",
35+
"babel-plugin-component": "^1.1.1",
3536
"babel-plugin-import": "^1.13.3",
3637
"babel-plugin-syntax-async-functions": "^6.13.0",
3738
"chalk": "^4.1.0",

example/pnpm-lock.yaml

Lines changed: 23 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/src/element-variables.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
$--font-path: "element-ui/lib/theme-chalk/fonts";
2+
3+
@import "~element-ui/packages/theme-chalk/src/base.scss";
4+
@import "~element-ui/packages/theme-chalk/src/form.scss";
5+
@import "~element-ui/packages/theme-chalk/src/form-item.scss";
6+
@import "~element-ui/packages/theme-chalk/src/button.scss";
7+
@import "~element-ui/packages/theme-chalk/src/row.scss";
8+
@import "~element-ui/packages/theme-chalk/src/col.scss";
9+
@import "~element-ui/packages/theme-chalk/src/input.scss";
10+
@import "~element-ui/packages/theme-chalk/src/input-number.scss";
11+
@import "~element-ui/packages/theme-chalk/src/switch.scss";

example/src/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
33
import Vue from 'vue'
44
import App from './App'
5-
import ElementUI from 'element-ui'
6-
import 'element-ui/lib/theme-chalk/index.css'
5+
import plugins from './plugins'
6+
import './element-variables.scss'
77

88
Vue.config.productionTip = false
9-
Vue.use(ElementUI)
9+
Vue.use(plugins)
1010
/* eslint-disable no-new */
1111
new Vue({
1212
el: '#app',

example/src/plugins.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {
2+
Form,
3+
Row,
4+
Col,
5+
FormItem,
6+
Input,
7+
Switch,
8+
InputNumber,
9+
Button,
10+
Checkbox
11+
} from 'element-ui'
12+
13+
export default {
14+
install (Vue) {
15+
Vue.use(Form)
16+
Vue.use(Row)
17+
Vue.use(Col)
18+
Vue.use(FormItem)
19+
Vue.use(Input)
20+
Vue.use(Switch)
21+
Vue.use(InputNumber)
22+
Vue.use(Button)
23+
Vue.use(Checkbox)
24+
}
25+
}

0 commit comments

Comments
 (0)