webpack-dev-middleware
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
colorette | 2.0.20 | 4.94 kB | MIT | prod | |
memfs | 4.9.2 | 645.54 kB | Apache-2.0 | prod | 5 |
mime-types | 2.1.35 | 5.46 kB | MIT | prod | |
range-parser | 1.2.1 | 3.52 kB | MIT | prod | |
schema-utils | 4.2.0 | 15.34 kB | MIT | prod |
Webpack-dev-middleware is a development middleware designed to be used with webpack. It is useful in development settings due to several key features. Firstly, it handles files in memory rather than writing them to your disk. It also delays requests when files change in watch mode until the compiling process is complete. Lastly, it supports hot module reload (HMR), a valuable feature during development.
To start using webpack-dev-middleware, you need to install the module using npm, ideally as a dev dependency. The code sample below illustrates a typical usage scenario in Node.js with Express.
const webpack = require("webpack");
const middleware = require("webpack-dev-middleware");
const compiler = webpack({
// your webpack configuration goes here
});
const express = require("express");
const app = express();
app.use(
middleware(compiler, {
// options for webpack-dev-middleware go here
})
);
app.listen(3000, () => console.log("Server listening on port 3000!"));
In this example, webpack-dev-middleware is being used as an Express middleware by calling app.use()
. It requires two arguments - a webpack compiler with your configuration and an options object for webpack-dev-middleware.
The documentation for webpack-dev-middleware can be found attached to the webpack.js.org website. The documentation provides a detailed explanation about the usage, API, options, and some FAQs about webpack-dev-middleware. Be sure to check out the documentation for more details and usage examples.