# saqu

> 使用 rspack 进行封装.

Latest version **0.1.40** (published 2024-10-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install saqu
pnpm add saqu
yarn add saqu
bun add saqu
```

Provides the command `saqu`.

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.40 |
| Published | 2024-10-24 |
| First published | 2023-04-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 19 |
| Unpacked size | 134.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | SunLxy |
| Maintainers | sunluxy |

## Links

- npm: https://www.npmjs.com/package/saqu
- Repository: https://github.com/SunLxy/saqu
- Homepage: https://github.com/SunLxy/saqu#readme
- Issues: https://github.com/SunLxy/saqu/issues
- npm.io page: https://npm.io/package/saqu

## Dependencies (19)

- [chalk](https://npm.io/package/chalk.md) 4.1.2
- [chokidar](https://npm.io/package/chokidar.md) ~3.5.3
- [fs-extra](https://npm.io/package/fs-extra.md) ~11.1.0
- [@swc/core](https://npm.io/package/@swc/core.md) 1.3.96
- [mocker-api](https://npm.io/package/mocker-api.md) ~2.9.5
- [typescript](https://npm.io/package/typescript.md) ~5.2.2
- [file-loader](https://npm.io/package/file-loader.md) ~6.2.0
- [@rspack/core](https://npm.io/package/@rspack/core.md) ^0.4.1
- [yargs-parser](https://npm.io/package/yargs-parser.md) ~21.1.1
- [@svgr/webpack](https://npm.io/package/@svgr/webpack.md) ^7.0.0
- [react-refresh](https://npm.io/package/react-refresh.md) 0.14.0
- [carefree-proload](https://npm.io/package/carefree-proload.md) ~0.0.2
- [@proload/plugin-rc](https://npm.io/package/@proload/plugin-rc.md) ~0.2.1
- [@rspack/dev-server](https://npm.io/package/@rspack/dev-server.md) ^0.4.1
- [@saqu/swc-register](https://npm.io/package/@saqu/swc-register.md) ^0.1.40
- [@proload/plugin-json](https://npm.io/package/@proload/plugin-json.md) ~0.3.1
- [webpack-node-externals](https://npm.io/package/webpack-node-externals.md) ~3.0.0
- [webpack-bundle-analyzer](https://npm.io/package/webpack-bundle-analyzer.md) ~4.8.0
- [@rspack/plugin-react-refresh](https://npm.io/package/@rspack/plugin-react-refresh.md) ~0.4.1

## Recent versions

- 0.1.40 (latest) — 2024-10-24
- 0.1.39 — 2024-04-29
- 0.1.38 — 2024-04-02
- 0.1.37 — 2023-11-22
- 0.1.36 — 2023-09-22
- 0.1.35 — 2023-09-04
- 0.1.34 — 2023-09-02
- 0.1.33 — 2023-08-31
- 0.1.32 — 2023-08-31
- 0.1.31 — 2023-08-29
- 0.1.30 — 2023-08-28
- 0.1.29 — 2023-08-28
- 0.1.28 — 2023-08-28
- 0.1.27 — 2023-08-18
- 0.1.26 — 2023-08-11
- … 49 more at https://npm.io/package/saqu/versions

## README

saqu
===

## 参考对象

1. 参考 `react-scripts` webpack 进行 配置

## 功能

- [X] 正常的项目进行打包和开发
- [X] md文档解析代码块进行渲染
- [X] import引入替换
- [X] 支持自动对入口文件进行生成
- [X] 支持自动生成路由
- [ ] 添加项目`app.{ts,tsx,jsx,js}`可以对路由之类的进行操作和配置
- [ ] 添加支持直接使用md文件做路由进行渲染md内容

## 安装

```bash
$ npm install saqu # yarn add saqu
```
## 命令

```bash
Usage: saqu [start|build] [--help|h]
  Displays help information.
Options:
  --help, -h              Displays help information.
Example:
$ saqu  build
$ saqu  start

```

## 快速创建项目

```bash
$ npx create-saqu my-app
```

## 配置参数

```ts
import { RspackOptions, SwcJsMinimizerRspackPluginOptions } from '@rspack/core';
import express from 'express';
import { MockerProxyRoute, MockerOption } from 'mocker-api';
import { DevServer } from '@rspack/core';
import yargsParser from 'yargs-parser';

/**
 * @description rspack 运行配置
 */
export interface SAquConfig extends RspackOptions {
  /**
   * @description 配置代理，可用于解决跨域等问题
   * @example
   * proxy: {
   *  '/api': {
   *    target: 'http://localhost:3000',
   *    changeOrigin: true,
   *  },
   * },
   * */
  proxy?: DevServer['proxy'];
  /**
   * @description mocker代理
   **/
  proxySetup?: (app: express.Application) =>
    | {
        path?: string | string[] | MockerProxyRoute;
        options?: MockerOption;
      }
    | undefined;
  /**
   * @description 重写环境配置
   */
  overridesRspack?: (
    config: RspackOptions,
    env: 'development' | 'production' | 'preview',
    argvOptions: SAquArgvOptions,
    type: 'server' | 'client',
  ) => Promise<RspackOptions> | RspackOptions;

  /**用来压缩 JS 产物 配置*/
  _JS_minifyOptions?: SwcJsMinimizerRspackPluginOptions;
}

/**
 * @description 命令行参数
 */
export interface SAquArgvOptions extends yargsParser.Arguments {
  /**
   * @description 使用 webpack-bundle-analyzer
   */
  analyze?: boolean;
  /**输出目录*/
  dir?: string;
  /**帮助*/
  help?: boolean;
  /**帮助(简写)*/
  h?: boolean;
}

```

## 基础配置

```ts
// .saqurc.ts
import { defineConfig } from "saqu"

export default ()=>defineConfig({
  // ...配置
})

```

## 重写配置

```ts
// .saqurc.ts
import { defineConfig } from "saqu"

export default ()=>defineConfig({
  // ...配置
  overridesRspack:(config,env,argvOptions,type)=>{
    return config;
  }
})

```

## 插件使用

```ts
// .saqurc.ts
import { defineConfig } from "saqu"
import createRoutes from '@saqu/auto-config-to-routes';

export default ()=>defineConfig({
  // ...配置
  plugins: [new createRoutes()],
})

```

## `entry`配置

默认入口文件`src/index.{js|tsx|jsx}`

当使用`!`开头的路径时，不进行校验文件是否存在(适用于自动生成入口文件)

其他情况会进行校验入口文件是否存在

```ts
// .saqurc.ts
import { defineConfig } from "saqu"
import createRoutes from '@saqu/auto-config-to-routes';

export default ()=>defineConfig({
  // ...配置
  entry: '!src/.cache/main.jsx',
})

```

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