网页
综合
更新时间 2026-11-14 16:20:47
webpack-dev-server API | webpack
自动蜘蛛
webpack.js.org
正文约 2502 字
webpack-dev-server provides a Node.js API which can be used directly in Node.js runtime.
To start using the webpack-dev-server Node.js API, first install webpack and webpack-dev-server if you haven’t yet:
Then require the modules in your Node.js script:
webpack-dev-server@6 requires Node.js 22.15.0 or higher and webpack 5.101.0 or higher.
Since version 6, the package source is native ESM. Prefer import syntax; CommonJS consumers can still require("webpack-dev-server") through the CommonJS build exposed via the exports field.
It instructs webpack-dev-server instance to start the server.
And then run the server with the following command:
It instructs webpack-dev-server instance to start the server and then run the callback function.
And then run the server with the following command:
It instructs webpack-dev-server instance to stop the server.
And then run the server with the following command:
It instructs webpack-dev-server instance to stop the server and then run the callback function.
And then run the server with the following command:
webpack-dev-server can be used as a webpack plugin, without explicitly passing a compiler to the constructor. The server integrates with the compiler lifecycle: it starts once the first compilation in watch mode completes, is not started multiple times on recompilation, and stops cleanly when the compiler is closed. MultiCompiler setups are supported as well, where each configuration can run its own plugin server.
Alternatively, call apply on an existing compiler:
In plugin mode the server only starts in watch mode: a one-shot compiler.run() build finishes without starting the server.
Returns the resolved local IP address synchronously, or undefined when no matching address is found.
The internalIP(family) and internalIPSync(family) static methods were removed in webpack-dev-server@6. Use findIp(family, false) to get the same result.
Copyright OpenJS Foundation and webpack contributors. All rights reserved. The OpenJS Foundation has registered trademarks and uses trademarks. For a list of trademarks of the OpenJS Foundation, please see our Trademark Policy and Trademark List. Trademarks and logos not indicated on the list of OpenJS Foundation trademarks are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.
The OpenJS Foundation | Terms of Use | Privacy Policy | Bylaws | Code of Conduct | Trademark Policy | Trademark List | Cookie Policy
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。