# get-umi-webpack-compiler

> get umi webpack compiler

Latest version **0.0.8** (published 2019-04-12) · 0 weekly downloads

## Install

```sh
npm install get-umi-webpack-compiler
pnpm add get-umi-webpack-compiler
yarn add get-umi-webpack-compiler
bun add get-umi-webpack-compiler
```

## 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.0.8 |
| Published | 2019-04-12 |
| First published | 2019-01-20 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 4 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | langshu, zhangyuang, zhaoxingyue |

## Links

- npm: https://www.npmjs.com/package/get-umi-webpack-compiler
- npm.io page: https://npm.io/package/get-umi-webpack-compiler

## Dependencies (4)

- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [webpack](https://npm.io/package/webpack.md) 4.28.4
- [umi-build-dev](https://npm.io/package/umi-build-dev.md) ^1.4.3
- [webpack-node-externals](https://npm.io/package/webpack-node-externals.md) ^1.7.2

## Recent versions

- 0.0.8 (latest) — 2019-04-12
- 0.0.7 — 2019-04-12
- 0.0.6 — 2019-03-27
- 0.0.5 — 2019-03-27
- 0.0.4 — 2019-01-21
- 0.0.3 — 2019-01-21
- 0.0.2 — 2019-01-21
- 0.0.1 — 2019-01-20

## README

# get-umi-webpack-compiler

react ssr 在dev环境下，需要获得webpack-compiler.

## Usages

```
const compiler = require('get-umi-webpack-compiler')(entry, dir)
```

示例

```
const compiler = require('.')({
  'app1':"@/pages/index.tsx"
}, process.cwd())
```

- entry是自定的入口，一般用于自定义的服务器端组件编译
- @是别名，指定src目录。
- 如果没dir参数，默认是process.cwd()

## Examples
下面是一个koa + dev + hot middleware的例子。

```
const Koa = require('koa');
const kwm = require('kwm');

const app = new Koa();

// get webpack-compiler from an umi project
const compiler = require('get-umi-webpack-compiler')()

// dev + hot middleware
app.use(kwm(compiler))

// response
app.use(async ctx => {
  ctx.body = Object.keys(ctx.state.webpackStats.compilation.assets);
});

app.listen(3000);
```

返回ctx.state.webpackStats.compilation.assets结果

```
["static/yay.44dd3333.jpg","layouts__index.chunk.css","layouts__index.async.js","p__index.chunk.css","p__index.async.js","umi.css","umi.js"]
```

## Test

```
const compiler = require('.')()
// 测试webpack执行情况
compiler.run((err, stats) => {/* ...处理结果 */
  if (err) console.dir(err)

  console.dir(stats)
})

```

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