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