# multi-env-webpack-plugin

> 根据环境解析不同的文件。 比如 src/index.js 解析 src/index.local.js

Latest version **1.1.0** (published 2021-07-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install multi-env-webpack-plugin
pnpm add multi-env-webpack-plugin
yarn add multi-env-webpack-plugin
bun add multi-env-webpack-plugin
```

## 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.1.0 |
| Published | 2021-07-05 |
| First published | 2021-04-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | liyatang |

## Links

- npm: https://www.npmjs.com/package/multi-env-webpack-plugin
- Repository: https://github.com/liyatang/multi-env-webpack-plugin
- Homepage: https://github.com/liyatang/multi-env-webpack-plugin#readme
- Issues: https://github.com/liyatang/multi-env-webpack-plugin/issues
- npm.io page: https://npm.io/package/multi-env-webpack-plugin

## Dependencies (2)

- [fs](https://npm.io/package/fs.md) ^0.0.1-security
- [path](https://npm.io/package/path.md) ^0.12.7

## Recent versions

- 1.1.0 (latest) — 2021-07-05
- 1.0.1 — 2021-04-14
- 1.0.0 — 2021-04-11

## README

# MultiEnvWebpackPlugin

根据环境解析不同的文件。 比如 src/index.js 解析 src/index.local.js

# 使用

webpack resolve plugins 引入
```javascript
const MultiEnvWebpackPlugin = require('multi-env-webpack-plugin')

const config = {
  resolve: {
    plugins: [ 
      new MultiEnvWebpackPlugin()
    ]
  }
}

```

在需要创建多端文件的地方创建一个 xxx.local.xx 文件

```text
app.jsx
app.local.jsx
```

记得 .gitignore 掉 xxx.local.xxx 文件哦

```text
*.local.tsx
*.local.ts
*.local.jsx
*.local.js
```

# 原理

TODO

# 参考

respect Taro 多端开发思想

[Taro 多端开发](https://taro-docs.jd.com/taro/docs/envs#%E8%AE%A9-node_modules-%E4%B8%AD%E7%9A%84%E4%BE%9D%E8%B5%96%E4%B9%9F%E8%83%BD%E8%A7%A3%E6%9E%90%E5%A4%9A%E7%AB%AF%E6%96%87%E4%BB%B6)

[MultiPlatformPlugin](https://github.com/NervJS/taro/blob/next/packages/taro-runner-utils/src/resolve/MultiPlatformPlugin.ts)

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