https://github.com/tqma113/koa-webpack-dev-middleware
Webpack dev middleware for koa2.x with typescript.
https://github.com/tqma113/koa-webpack-dev-middleware
koa webpack webpack-dev-middleware
Last synced: 12 months ago
JSON representation
Webpack dev middleware for koa2.x with typescript.
- Host: GitHub
- URL: https://github.com/tqma113/koa-webpack-dev-middleware
- Owner: tqma113
- License: mit
- Created: 2019-10-03T06:15:46.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-11T12:23:54.000Z (almost 6 years ago)
- Last Synced: 2025-03-03T23:06:34.967Z (about 1 year ago)
- Topics: koa, webpack, webpack-dev-middleware
- Language: TypeScript
- Size: 134 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HIstory.md
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
README
# koa-webpack-dev-middleware
A development middleware for koa2.x with typescript for use with webpack bundles.
## Requirements
This module requires a minimum of Node v10.16.3 and Webpack v4.41.0, and must be used with a server that accepts koa2.x-style middleware.
## Get started
First thing's first, install the module.
npm:
```console
npm install --save-dev koa-wdm
```
yarn:
```console
yarn add -D koa-wdm
```
## Usage
```js
import Koa from 'koa'
import webpack from 'webpack'
import webpackConfig from './webpack.config'
import getMiddleware from '../src/index'
const app = new Koa()
const compiler = webpack(webpackConfig)
app.use(getMiddleware(compiler))
app.listen(8080, () => {
console.log('start at 8080')
})
```
## Options
The middleware accept a object to change some behavior.
It also support zero config.
### index
The index path for web server, defaults to "index.html".
Type: string
Default: index.html
### log
In the rare event that a user would like to provide a custom logging interface, this property allows the user to assign one. Created with [ansi-colors](https://github.com/doowb/ansi-colors)
Type: Out(An object consist of 5 function attributes, log, info, debug, warn, error)
Default: [Logger](https://github.com/tqma113/koa-webpack-dev-middleware/blob/master/src/utils/logger/index.ts)
### displayStats
It controller if ouput the log message.
Type: boolean
Default: true
### stats
Options for formatting statistics displayed during and after compile. For more information and property details, please see the [webpack documentation](https://webpack.js.org/configuration/stats/#stats).
Type: boolean
Default:
```js
{
context: process.cwd(),
colors: true,
}
```
## License
[MIT](https://github.com/tqma113/koa-webpack-dev-middleware/blob/master/LICENSE)