Open pearlwang1106 opened 4 years ago
Hmmm ... you're using a babel plugin as a VuePress plugin, I suggest that you need read docs of VuePress's Plugin API again.
It seems that you need to config extra babel plugin, it's a valid feature request.
I've managed to make this work by piecing together these 2 great answers:
This is how you would configure the babel-plugin-component to work with VuePress:
....
chainWebpack: (config, isServer) => {
// Thanks to https://github.com/vuejs/vuepress/issues/969#issuecomment-434193517
// https://stackoverflow.com/a/52121492/4017403
config.module
.rule('js') // Find the rule.
.use('babel-loader') // Find the loader
.tap(options => Object.assign(options, { // Modifying options
plugins: [
["component", {
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}]
]
}))
},
....
Then you would selectively import your components as suggested by the VuePress Docs here
This has been open for a while, so I am not sure if it's of use to anybody :sweat_smile:
I've managed to make this work by piecing together these 2 great answers:
- https://stackoverflow.com/a/52121492/4017403
- How i can add .babelrc file use plugin babel-plugin-import lazyload ui-component #969 (comment)
This is how you would configure the babel-plugin-component to work with VuePress:
.... chainWebpack: (config, isServer) => { // Thanks to https://github.com/vuejs/vuepress/issues/969#issuecomment-434193517 // https://stackoverflow.com/a/52121492/4017403 config.module .rule('js') // Find the rule. .use('babel-loader') // Find the loader .tap(options => Object.assign(options, { // Modifying options plugins: [ ["component", { "libraryName": "element-ui", "styleLibraryName": "theme-chalk" }] ] })) }, ....
Then you would selectively import your components as suggested by the VuePress Docs here
This has been open for a while, so I am not sure if it's of use to anybody 😅
I use your method, but only 1 MB of capacity is compressed. Is this normal?
I've managed to make this work by piecing together these 2 great answers:
- https://stackoverflow.com/a/52121492/4017403
- How i can add .babelrc file use plugin babel-plugin-import lazyload ui-component #969 (comment)
This is how you would configure the babel-plugin-component to work with VuePress:
.... chainWebpack: (config, isServer) => { // Thanks to https://github.com/vuejs/vuepress/issues/969#issuecomment-434193517 // https://stackoverflow.com/a/52121492/4017403 config.module .rule('js') // Find the rule. .use('babel-loader') // Find the loader .tap(options => Object.assign(options, { // Modifying options plugins: [ ["component", { "libraryName": "element-ui", "styleLibraryName": "theme-chalk" }] ] })) }, ....
Then you would selectively import your components as suggested by the VuePress Docs here
This has been open for a while, so I am not sure if it's of use to anybody 😅
This is really helpful. Thanks a lot!
Feature request
引入element-ui,并且实现按需加载,该如何设置
如下配置不生效: