# @yme/taro-plugin-pages

> > taro-plugin-pages 是一个用于 Taro 的插件，用于自动生成 pages 配置。

Latest version **0.1.0** (published 2024-08-07) · 0 weekly downloads

## Install

```sh
npm install @yme/taro-plugin-pages
pnpm add @yme/taro-plugin-pages
yarn add @yme/taro-plugin-pages
bun add @yme/taro-plugin-pages
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2024-08-07 |
| First published | 2023-06-08 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | mino |
| Maintainers | minosss |

## Links

- npm: https://www.npmjs.com/package/@yme/taro-plugin-pages
- Repository: https://github.com/minosss/taro-plugin-pages
- Homepage: https://github.com/minosss/taro-plugin-pages#readme
- Issues: https://github.com/minosss/taro-plugin-pages/issues
- npm.io page: https://npm.io/package/@yme/taro-plugin-pages

## Dependencies (1)

- [fast-glob](https://npm.io/package/fast-glob.md) ^3.2.12

## Recent versions

- 0.1.0 (latest) — 2024-08-07
- 0.0.2 — 2024-04-13
- 0.0.1 — 2023-06-08

## README

# taro-plugin-pages

> taro-plugin-pages 是一个用于 Taro 的插件，用于自动生成 pages 配置。

**注意: `0.1.0` 开始使用了 `/* pages start */` 的标识来替换页面内容**

1. 自动更新 `app.config.ts` 下的 `pages` 字段。可以关闭格式化，避免文件每次都更新。

```js
export default defineAppConfig({
  /* eslint-disable */
  /* pages start */
  pages: [
    'pages/home/page',
    'pages/launch/page',
    'pages/auth/login/page',
    'pages/auth/register/page',
  ],
  /* pages end */
  /* eslint-enable */
});
```

2. 自动更新 `utils/pages.ts` 文件。根据文件夹层级生成对象。

```js
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// 由组件 generate-pages 生成，不要改
export default {
  "home": "/pages/home/page",
  "launch": "/pages/launch/page",
  "auth": {
    "login": "/pages/auth/login/page",
    "register": "/pages/auth/register/page"
  }
} as const;
```

3. 分包配置

在配置文件中添加 subPackages 字段

- 分包目录需在页面目录下，比如 `pages/@xx`
- 分包使用前缀 `@` `@@` 标志
- `@` 分包
- `@@` 独立分包，有 `independent`
- 分包的前缀不会在页面对象中显示，`@` 会被换成 `_`，方便这样 `pages.__sub.your.page` 的格式

```js
export default defineAppConfig({
  /* subPackages start */
  subPackages: [],
  /* subPackages end */
});
```

## 安装

```bash
npm i @yme/taro-plugin-pages -D
```

## 使用

在 `config/index.js` 中配置插件，如果你没用 ts 需要自定义配置

```js
{
  plugins: [
    ['@yme/taro-plugin-pages', {
      // 通常都不需要改
      // 页面存放的目录
      // dir: 'pages',
      // 页面的文件名
      // pageName: 'page.vue',
      // 页面对象的储存文件
      // pagesName: 'utils/pages.ts',
      // 应用页面配置文件
      // appConfigName: 'app.config.ts',
    }]
  ]
}
```

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