express-webpack
Development and Hot Module Reload middleware for Express
This module implements webpack-dev-middleware and webpack-hot-client into a single middleware.
Install
Using npm:
npm install express-webpack --save-dev
Usage
See /examples for an examples of usage.
const express = const expressWebpack = const app = const middleware = await app
Options
configPath
By default it will use your webpack.config.js
located in your root directory but you can set a diferent path using this option.
const express = const expressWebpack = const app = const middleware = await app
config
You can pass a webpack configuratin object using this option.
const express = const expressWebpack = const config = mode: 'development' entry: './src' output: publicPath: '/' const app = const middleware = await app
compiler
You can pass your own webpack compiler using this option.
const webpack = const express = const expressWebpack = const config = const app = const compiler = const middleware = await app
hotClient
You can override the default options set by webpack-hot-client by setting an object with the availables options for the webpack-hot-client or shutdown the HMR by setting this option to false
.
devMiddleware
You can override the default options set by webpack-dev-middleware by setting an object with the availables options for the webpack-dev-middleware
API
expressWebpack([options])
Returns a Promise
which resolves in an object with the following properties:
-
middleware
(Object) - Middleware for development and HMR -
close(callback)
(Function) - Close both instances ofwebpack-dev-middleware
andwebpack-hot-middleware
if enabled. Receive a callback function which is executed when both instances are closed. -
hotClient
(Object) - An instance ofwebpack-hot-client
. -
devMiddleware
(Object) - An instance ofwebpack-dev-middleware
.