# miniapp-compile-config

> miniapp compile project config

Latest version **0.3.3** (published 2022-09-16) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install miniapp-compile-config
pnpm add miniapp-compile-config
yarn add miniapp-compile-config
bun add miniapp-compile-config
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.3 |
| Published | 2022-09-16 |
| First published | 2020-08-25 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 12 |
| Unpacked size | 52.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 74 |
| Author | Rax Team |
| Maintainers | rax-publisher |

## Links

- npm: https://www.npmjs.com/package/miniapp-compile-config
- Repository: https://github.com/raxjs/miniapp
- Homepage: https://github.com/raxjs/miniapp#readme
- Issues: https://github.com/raxjs/miniapp/issues
- npm.io page: https://npm.io/package/miniapp-compile-config

## Dependencies (12)

- [terser](https://npm.io/package/terser.md) ^4.8.0
- [chokidar](https://npm.io/package/chokidar.md) ^3.4.2
- [fs-extra](https://npm.io/package/fs-extra.md) ^8.0.1
- [memory-fs](https://npm.io/package/memory-fs.md) ^0.5.0
- [ts-loader](https://npm.io/package/ts-loader.md) ^8.0.0
- [json-loader](https://npm.io/package/json-loader.md) ^0.5.7
- [jsx2mp-loader](https://npm.io/package/jsx2mp-loader.md) ^0.4.33
- [jsx2mp-runtime](https://npm.io/package/jsx2mp-runtime.md) ^0.4.18
- [copy-webpack-plugin](https://npm.io/package/copy-webpack-plugin.md) ^5.0.4
- [rax-platform-loader](https://npm.io/package/rax-platform-loader.md) ^1.0.2
- [miniapp-builder-shared](https://npm.io/package/miniapp-builder-shared.md) ^0.3.0
- [rax-miniapp-config-webpack-plugin](https://npm.io/package/rax-miniapp-config-webpack-plugin.md) ^3.0.0

## Recent versions

- 0.3.3 (latest) — 2022-09-16
- 0.3.4-1 (beta) — 2022-12-05
- 0.3.0-alpha.2 (alpha) — 2021-12-08
- 0.3.0-rc.2 (rc) — 2021-12-02
- 0.3.3-1 — 2022-08-11
- 0.3.3-0 — 2022-01-12
- 0.3.2 — 2022-01-12
- 0.3.1 — 2021-12-23
- 0.3.1-beta.1 — 2021-12-16
- 0.3.0 — 2021-12-15
- 0.2.6-4 — 2021-12-03
- 0.2.6-3 — 2021-12-03
- 0.3.0-rc.1 — 2021-12-02
- 0.2.6-2 — 2021-11-25
- 0.2.6-1 — 2021-11-25
- … 32 more at https://npm.io/package/miniapp-compile-config/versions

## README

### miniapp-compile-config
小程序编译时工程公共配置设置。

### 方法
#### setAppConfig
##### 参数

| 参数       | 类型   | 默认值 | 必填 | 描述                                                         |
| ---------- | ------ | ------ | ---- | ------------------------------------------------------------ |
| config     | object | -      | ✔️    | webpack chain config                                         |
| userConfig | object | {}     |  ✘   | 当前小程序平台的用户配置，例如 `{ nativeConfig: { appId: 123 } }` |
| options    | object | -      | ✔️    | options 子项见下表


##### options 子项

| 参数          | 类型   | 默认值 | 必填 | 描述                                                         |
| ------------- | ------ | ------ | ---- | ------------------------------------------------------------ |
| context       | object | -      | ✔️    | build plugin 上下文变量，包含运行时的各种环境信息            |
| target        | string | -      | ✔️    | 构建的小程序平台类型，例如 `miniapp`/`wechat-miniprogram`    |
| onGetWebpackConfig | function | -      | ✔️      | 在工程获取 webpack 时触发的函数，可以在 build plugin 的 api 中获取  |
| entryPath       | string | -      | ✔️    | 入口路径           |
| outputPath        | string | -      | ✔️    | 输出路径    |


#### setComponentConfig
##### 参数

| 参数       | 类型   | 默认值 | 必填 | 描述                                                         |
| ---------- | ------ | ------ | ---- | ------------------------------------------------------------ |
| config     | object | -      | ✔️    | webpack chain config                                         |
| userConfig | object | {}     |  ✘   | 当前小程序平台的用户配置，例如 `{ nativeConfig: { appId: 123 } }` |
| options    | object | -      | ✔️    | options 子项见下表


##### options 子项

| 参数          | 类型   | 默认值 | 必填 | 描述                                                         |
| ------------- | ------ | ------ | ---- | ------------------------------------------------------------ |
| context       | object | -      | ✔️    | build plugin 上下文变量，包含运行时的各种环境信息            |
| target        | string | -      | ✔️    | 构建的小程序平台类型，例如 `miniapp`/`wechat-miniprogram`    |
| entryPath       | string | -      | ✔️    | 入口路径           |
| outputPath        | string | -      | ✔️    | 输出路径    |

### 使用

```js
const { setAppConfig, setComponentConfig } = require('miniapp-compile-config');

// 应用
setAppConfig(config, userConfig, { context, target, onGetWebpackConfig, entryPath, outputPath });

// 组件
setComponentConfig(config, userConfig, { context, target, onGetWebpackConfig, entryPath, outputPath });
```

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