# babel-plugin-ynw

> 1.安装

Latest version **1.0.0** (published 2018-08-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-ynw
pnpm add babel-plugin-ynw
yarn add babel-plugin-ynw
bun add babel-plugin-ynw
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-08-02 |
| First published | 2018-05-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | liqiang0335 |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-ynw
- Repository: https://github.com/liqiang0335/babel-plugin-ynw
- Homepage: https://github.com/liqiang0335/babel-plugin-ynw#readme
- Issues: https://github.com/liqiang0335/babel-plugin-ynw/issues
- npm.io page: https://npm.io/package/babel-plugin-ynw

## Dependencies (1)

- [babel-core](https://npm.io/package/babel-core.md) ^6.26.3

## Recent versions

- 1.0.0 (latest) — 2018-08-02
- 0.0.9 — 2018-06-16
- 0.0.8 — 2018-05-28
- 0.0.7 — 2018-05-28
- 0.0.6 — 2018-05-28
- 0.0.4 — 2018-05-27
- 0.0.2 — 2018-05-25
- 0.0.1 — 2018-05-25

## README

# babel-plugin-ynw

## 使用

1.安装

```js
npm i --save-dev babel-plugin-ynw
```

2.配置

```js
// .babelrc文件
{
  plugins: ["ynw"];
}
```

## ynRegisteVueComps

> 自动注册 Vue 组件

```js
// 自动注册 comps 文件夹下面的 .vue 文件为  VUE 组件 (带有 yn 前缀)
// 出于性能的考虑, 没有设置自定义参数, 也就是说需要把组件放在 "comps" 文件夹
ynRegisteVueComps();

// 以上一行代码会转义为这一坨代码
const compContext = require.context("./comps", true, /\.vue$/);
compContext.keys().forEach(p => {
  const getCompPathName = path => {
    const match = path.match(/\w+?(?=\/)/g);
    if (!match) return "";
    return match.map(item => item.replace(/\//g, "")).join("-") + "-";
  };
  const name = p.match(/([\w\-]+)\.vue$/)[1];
  const folder = getCompPathName(p);
  const option = compContext(p).default;
  Vue.component("yn-" + folder + name, option);
});
```

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