Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 8, 2019. It is now read-only.
/docsPublic archive

webpack dev middleware

HQidea edited this pageDec 29, 2016 ·13 revisions

Note: The webpack-dev-middleware is for advanced users. Seewebpack-dev-server for a ready-to-use solution.
Note: For multiple webpackconfiguration seemiddware ordev-middleware
If you are looking for this middleware forkoa2 ecosystem loaded with HMR support see atkoa-webpack-middleware.

Thewebpack-dev-middleware is a small middleware for a connect-based middleware stack. It uses webpack to compile assets in-memory and serve them. When a compilation is running every request to the served webpack assets is blocked until we have a stable bundle.

You can use it in two modes:

  • watch mode (default): The compiler recompiles on file change.
  • lazy mode: The compiler compiles on every request to the entry point.

API

varwebpackDevMiddleware=require("webpack-dev-middleware");varwebpack=require("webpack");varcompiler=webpack({// configurationoutput:{path:'/'}});app.use(webpackDevMiddleware(compiler,{// options}));

options

noInfo

Display no info to console (only warnings and errors)

Default:false

quiet

Display nothing to the console

Default:false

lazy

Switch into lazy mode.

Default:false

In lazy mode: Switch request should trigger the compilation.

filename

In most cases this equals the webpack configuration optionoutput.filename.

watchOptions.aggregateTimeout

Delay the rebuilt after the first change. Value is a time in ms.

Default:300

watchOptions.poll

true: use polling

number: use polling with specified interval

Default:undefined

publicPath (required)

The path where to bind the middleware to the server.

In most cases this equals the webpack configuration optionoutput.publicPath.

headers

Add custom headers. i. e.{ "X-Custom-Header": "yes" }

stats

Output options for the stats. Seenode.js API.

middleware.invalidate()

Manually invalidate the compilation. Useful if stuff of the compiler has changed.

middleware.fileSystem

A readable (in-memory) filesystem that can access the compiled data.

webpack 👍

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp