0.1.0-alpha.0 • Published 2 years ago
@tawa/babel-plugin-import v0.1.0-alpha.0
@tawa/babel-plugin-import
tawa babel import plugin
Example
// input code
import { Input } from 'tawa';
// output code
('use strict');
import Input from 'tawa/input/es';
import 'tawa/input/es/style/index.less';
// input code
import Input from '@tawa';
// output code
('use strict');
import Input from '@tawa';
import '@tawa/input/es/style/index.less';
Installation
$ npm install @tawa/babel-plugin-import
Usage
Via .babelrc
(Recommended)
.babelrc
{
"plugins"
:
[
[
"@tawa/babel-plugin-import",
{
"libraryName": "tawa",
"libraryDirectory": "es",
"style": true
}
]
]
}
Via CLI
$ babel --plugins @tawa/babel-plugin-import script.js
Via Node API
require('babel-core').transform('code', {
plugins: ['@tawa/babel-plugin-import'],
});
Options
Option | Description | Type | Default |
---|---|---|---|
style | 用于设置需要引入的样式文件的后缀 | boolean | false |
customStyleName | 用于设置需要引入的样式文件名称。默认为 index.xxx | string | - |
libraryDirectory | 用于设置引入 js 文件所在的文件目录 | string | lib |
actualStyleDirectoryPath | 实际的 style 文件夹路径,用于判断 style 文件是否存在 | function | - |
libraryName | library name | string | - |
importedNamePrefix | 引入变量名前缀 | string | - |
styleLibraryDirectory | 样式文件所在目录 | string | - |
customNormalizeModuleName | 自定义转换模块名称方式 | function | - |
actualImportLibraryName | 实际 import 的 library name | string | - |
0.1.0-alpha.0
2 years ago
0.0.1
2 years ago