# @tawa/babel-plugin-import

> tawa babel import plugin

Latest version **0.1.0-alpha.0** (published 2022-10-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install @tawa/babel-plugin-import
pnpm add @tawa/babel-plugin-import
yarn add @tawa/babel-plugin-import
bun add @tawa/babel-plugin-import
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0-alpha.0 |
| Published | 2022-10-19 |
| First published | 2022-10-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 9.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | nanz |
| Maintainers | xiaoshiming, thefirstsunday |

## Links

- npm: https://www.npmjs.com/package/@tawa/babel-plugin-import
- Repository: https://github.com/tawa-cn/create-tawa-app
- Homepage: https://github.com/tawa-cn/create-tawa-app#readme
- Issues: https://github.com/tawa-cn/create-tawa-app/issues
- npm.io page: https://npm.io/package/@tawa/babel-plugin-import

## Dependencies (2)

- [assert](https://npm.io/package/assert.md) ^2.0.0
- [is-plain-object](https://npm.io/package/is-plain-object.md) ^5.0.0

## Recent versions

- 0.1.0-alpha.0 (latest) — 2022-10-19
- 0.0.1 — 2022-10-09

## README

# @tawa/babel-plugin-import

tawa babel import plugin

## Example

```js
// input code
import { Input } from 'tawa';

// output code
('use strict');
import Input from 'tawa/input/es';
import 'tawa/input/es/style/index.less';
```

```js
// input code
import Input from '@tawa';

// output code
('use strict');
import Input from '@tawa';
import '@tawa/input/es/style/index.less';
```

## Installation

```sh
$ npm install @tawa/babel-plugin-import
```

## Usage

### Via `.babelrc` (Recommended)

**.babelrc**

```javascript
{
  "plugins"
:
  [
    [
      "@tawa/babel-plugin-import",
      {
        "libraryName": "tawa",
        "libraryDirectory": "es",
        "style": true
      }
    ]
  ]
}
```

### Via CLI

```sh
$ babel --plugins @tawa/babel-plugin-import script.js
```

### Via Node API

```javascript
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   | -       |

---
_Source: https://npm.io/package/@tawa/babel-plugin-import · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
