/babel-plugin-auto-import-jweboy

babel模块化导入插件

Primary LanguageJavaScriptMIT LicenseMIT

babel-plugin-auto-import-jweboy

babel模块化导入插件,实现了按需加载的功能来满足常规业务需求。 Build Status

Useage

npm install babel-plugin-auto-import-jweboy --save-dev

yarn add babel-plugin-auto-import-jweboy --dev

在.babelrc增加配置

{
    "plugins": ["auto-import-jweboy", options]
}

Options

options是一个对象类型

模块化导入js

{
    "libraryName": "test-ui"
}

模块化按需导入js、css

{
    "libraryName": "test-ui",
    "style": true
}

Example

{ "libraryName": "test-ui" }
Before compiling:
import { Button } from 'test-ui'

After compilation:
var _Button = _interopRequireDefault(require("test-ui/lib/Button"));
{ "libraryName": "test-ui", "style": true }
Before compiling:
import { Button } from 'test-ui'

After compilation:
require("test-ui/lib/Button/style");
var _Button = _interopRequireDefault(require("test-ui/lib/Button"));