1 | # koa-webpack-dev-middleware
|
2 |
|
3 | webpack dev middleware for koa
|
4 |
|
5 |
|
6 | ## Usage
|
7 |
|
8 | same with https://github.com/webpack/webpack-dev-middleware
|
9 |
|
10 | ```js
|
11 | var app = require('koa')();
|
12 | var webpackMiddleware = require("koa-webpack-dev-middleware");
|
13 | app.use(webpackMiddleware(...));
|
14 | ```
|
15 |
|
16 | ### Example usage
|
17 |
|
18 | ```js
|
19 | var app = require('koa')();
|
20 | app.use(webpackMiddleware(webpack({
|
21 | // webpack options
|
22 | // webpackMiddleware takes a Compiler object as first parameter
|
23 | // which is returned by webpack(...) without callback.
|
24 | entry: "...",
|
25 | output: {
|
26 | path: "/"
|
27 | // no real path is required, just pass "/"
|
28 | // but it will work with other paths too.
|
29 | }
|
30 | }), {
|
31 | // all options optional
|
32 |
|
33 | noInfo: false,
|
34 | // display no info to console (only warnings and errors)
|
35 |
|
36 | quiet: false,
|
37 | // display nothing to the console
|
38 |
|
39 | lazy: true,
|
40 | // switch into lazy mode
|
41 | // that means no watching, but recompilation on every request
|
42 |
|
43 | watchDelay: 300,
|
44 | // delay after change (only lazy: false)
|
45 |
|
46 | publicPath: "/assets/",
|
47 | // public path to bind the middleware to
|
48 | // use the same as in webpack
|
49 |
|
50 | headers: { "X-Custom-Header": "yes" },
|
51 | // custom headers
|
52 |
|
53 | stats: {
|
54 | colors: true
|
55 | }
|
56 | // options for formating the statistics
|
57 | }));
|
58 | ``` |
\ | No newline at end of file |