-
Notifications
You must be signed in to change notification settings - Fork 0
webpack dev middleware.cn
Note: The webpack-dev-middleware is for advanced users. See webpack-dev-server for a ready-to-use solution.
Note: For multiple webpack configuration see middware or dev-middleware
If you are looking for this middleware for koa2 ecosystem loaded by HMR support see at koa-webpack-middleware.
注意:webpack-dev-middleware是给高级用户用的。即取即用的解决方案请参见webpack-dev-server
注意:对于多个 webpack configuration 参见 middware or dev-middleware
如果你在找寻支持 HMR 加载的、面向koa2生态的中间件,参见koa-webpack-middleware
The webpack-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.
webpack-dev-middleware是一个面向基于连接的中间件堆栈的小型中间件。其使用webpack来在内存中编译资源并提供资源访问服务。当一次编译正在运行,对提供的webpack资源的每一个请求都会被阻塞,直到编译打包完成。
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.
你可以在两种模式下使用:
- 监视模式(默认):文件更改时编译器重新编译。
- 懒人模式:每个对入口点的请求触发编译器启动编译。
var webpackDevMiddleware = require("webpack-dev-middleware");
var webpack = require("webpack");
var compiler = webpack({
// configuration
output: { path: '/' }
});
app.use(webpackDevMiddleware(compiler, {
// options
}));
Display no info to console (only warnings and errors)
不显示信息到控制台(仅限于警告和错误)
Default: false
Display nothing to the console
控制台什么也不显示
Default: false
Switch into lazy mode.
切换到懒人模式。
Default: false
In lazy mode: Switch request should trigger the compilation.
懒人模式:Switch请求应该触发编译
In most cases this equals the webpack configuration option output.filename
.
在大多数情况下,这等于webpack配置选项output.filename
。
Delay the rebuilt after the first change. Value is a time in ms.
第一次变更后延迟重新构建。单位值是ms。
Default: 300
true
: use polling
true
: 使用轮询
number: use polling with specified interval
数字: 以指定的时间间隔进行轮询
Default: undefined
The path where to bind the middleware to the server.
中间件到服务器的绑定路径
In most cases this equals the webpack configuration option output.publicPath
.
在大多数情况下,这等于webpack配置选项output.publicPath
。
Add custom headers. i. e. { "X-Custom-Header": "yes" }
添加自定义头信息。如{ "X-Custom-Header": "yes" }
Output options for the stats. See node.js API.
统计信息的输出选项。参见 node.js API
Manually invalidate the compilation. Useful if stuff of the compiler has changed.
手动将编译设为无效。如果编译器的东西改变了,会有用处。
A readable (in-memory) filesystem that can access the compiled data.
可以访问编译数据的可读的(内存)文件系统。