0.2.7 • Published 5 years ago
@lexiang/babel-plugin-component v0.2.7
Introduction
lazy load component, base on babel-plugin-component
Install
yarn add @lexiang/babel-plugin-component -DUsage
Via .babelrc or babel-loader.
{
"plugins": [
["@lexiang/babel-plugin-component", options]
]
}options
- libraryName: module name
- styleLibraryName: style module name
- styleLibrary: Import a independent theme package with more config
styleLibrary: { "name": "xxx", // same with styleLibraryName "base": true, // if theme package has a base.css "path": "[module]/index.css", // the style path. e.g. module Alert => alert/index.css "mixin": true // if theme-package not found css file, then use [libraryName]'s css file } - style: import css from 'module/index.css', default
false - libDir: dist directory, default
lib - root: main file dir, default
index - camel2Dash: whether parse name to dash mode or not, default
true
Example
convert
import { button } from 'components';to
var button = require('components/lib/button');style Example
when it is set to true
convert
import { button } from 'components';to
var button = require('components/lib/button/index.css');