webpack-dev-middleware
- Version 8.6.3
- Published
- 780 kB
- 4 dependencies
- MIT license
Install
npm i webpack-dev-middlewareyarn add webpack-dev-middlewarepnpm add webpack-dev-middlewareOverview
A development middleware for webpack
Index
Functions
Type Aliases
- AdditionalMethods
- API
- Attach
- CacheOptions
- Callback
- Close
- Compilation
- Compiler
- Configuration
- Context
- EXPECTED_ANY
- EXPECTED_FUNCTION
- ExtendedServerResponse
- FilenameWithExtra
- FilledContext
- GetFilenameFromUrl
- HandleUpgrade
- HapiOptions
- HapiPlugin
- HapiPluginBase
- Headers
- HotInstance
- HotOptions
- IncomingMessage
- Invalidate
- Logger
- Middleware
- MimeOptions
- MimeTypes
- ModifyResponseData
- MultiCompiler
- MultiStats
- MultiStatsOptions
- MultiWatching
- NextFunction
- NormalizedHeaders
- NormalizedOptions
- OnConnect
- Options
- OutputFileSystem
- Publish
- PublishTo
- Readable
- ReadStream
- ResponseData
- Schema
- ServerResponse
- Stats
- StatsObjectOptions
- StatsOptions
- WaitUntilValid
- Watching
- WatchOptions
- WithOptional
- WithoutUndefined
Namespaces
Functions
function hapiWrapper
hapiWrapper: <HapiServer, HapiOptionsInternal extends HapiOptions>( usePlugin?: boolean | undefined) => HapiPlugin<HapiServer, HapiOptionsInternal>;HapiServer {HapiOptions} HapiOptionsInternal
Parameter usePlugin
true when need to use as a plugin, otherwise false
Returns
{HapiPlugin<HapiServer, HapiOptionsInternal>} hapi wrapper
function honoWrapper
honoWrapper: < RequestInternal extends any = any, ResponseInternal extends unknown = any>( compiler: Compiler | MultiCompiler, options?: Options<RequestInternal, ResponseInternal> | undefined, usePlugin?: boolean | undefined) => ((ctx: EXPECTED_ANY, next: EXPECTED_FUNCTION) => Promise<void> | void) & { devMiddleware: API<RequestInternal, ResponseInternal>;};{IncomingMessage} [RequestInternal=IncomingMessage] {ServerResponse} [ResponseInternal=ServerResponse]
Parameter compiler
compiler
Parameter options
options
Parameter usePlugin
true when need to use as a plugin, otherwise false
Returns
{((ctx: EXPECTED_ANY, next: EXPECTED_FUNCTION) => Promise | void) & { devMiddleware: API<RequestInternal, ResponseInternal> }} hono wrapper
function koaWrapper
koaWrapper: < RequestInternal extends any = any, ResponseInternal extends unknown = any>( compiler: Compiler | MultiCompiler, options?: Options<RequestInternal, ResponseInternal> | undefined, usePlugin?: boolean | undefined) => ((ctx: EXPECTED_ANY, next: EXPECTED_FUNCTION) => Promise<void> | void) & { devMiddleware: API<RequestInternal, ResponseInternal>;};{IncomingMessage} [RequestInternal=IncomingMessage] {ServerResponse} [ResponseInternal=ServerResponse]
Parameter compiler
compiler
Parameter options
options
Parameter usePlugin
whether to use as webpack plugin
Returns
{((ctx: EXPECTED_ANY, next: EXPECTED_FUNCTION) => Promise | void) & { devMiddleware: API<RequestInternal, ResponseInternal> }} koa wrapper
function wdm
wdm: typeof wdm;{IncomingMessage} [RequestInternal=IncomingMessage] {ServerResponse} [ResponseInternal=ServerResponse]
Parameter compiler
compiler
Parameter options
options
Parameter isPlugin
true when will use as a plugin, otherwise false
Returns
{API<RequestInternal, ResponseInternal>} webpack dev middleware
Type Aliases
type AdditionalMethods
type AdditionalMethods< RequestInternal extends IncomingMessage, ResponseInternal extends ServerResponse> = { /** * get filename from url */ getFilenameFromUrl: GetFilenameFromUrl; /** * wait until valid */ waitUntilValid: WaitUntilValid; /** * invalidate */ invalidate: Invalidate; /** * answer WebSocket upgrades on this server */ attach: Attach; /** * answer one WebSocket upgrade, for a server that owns its own `upgrade` event */ handleUpgrade: HandleUpgrade; /** * called with each client that joins, and the request it joined with */ onConnect: OnConnect; /** * put a payload of your own on the hot stream, for what a server measures itself — a no-op when `hot` is off */ publish: Publish; /** * put a payload on the hot stream for one client, for answering a single connection — whichever transport is carrying it, and a no-op when `hot` is off */ publishTo: PublishTo; /** * the secret the hot endpoint's client is given, for a client of your own to put on the url; false when there is none, undefined when `hot` is off */ token?: (string | false | undefined) | undefined; /** * close */ close: Close; /** * context */ context: Context<RequestInternal, ResponseInternal>;};type API
type API< RequestInternal extends IncomingMessage = import('node:http').IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = Middleware<RequestInternal, ResponseInternal> & AdditionalMethods<RequestInternal, ResponseInternal>;type Attach
type Attach = (server: import('node:http').Server) => any;type CacheOptions
type CacheOptions = { /** * generate an `ETag` header, weak or strong */ etag?: ('weak' | 'strong') | undefined; /** * generate a `Last-Modified` header from the file system's value */ lastModified?: boolean | undefined; /** * set a `Cache-Control` header */ control?: | ( | boolean | number | string | { maxAge?: number; immutable?: boolean; } ) | undefined; /** * send `Cache-Control: public, max-age=31536000, immutable` for an asset with a hash in its name */ immutable?: boolean | undefined;};type Callback
type Callback = (stats?: (Stats | MultiStats) | undefined) => any;type Close
type Close = (callback: (err: Error | null | undefined) => void) => any;type Compilation
type Compilation = import('webpack').Compilation;type Compiler
type Compiler = import('webpack').Compiler;type Configuration
type Configuration = import('webpack').Configuration;type Context
type Context< RequestInternal extends IncomingMessage = import('node:http').IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = { /** * state */ state: boolean; /** * stats */ stats: Stats | MultiStats | undefined; /** * callbacks */ callbacks: Callback[]; /** * options, with `cache` and `mime` filled in */ options: NormalizedOptions<RequestInternal, ResponseInternal>; /** * compiler */ compiler: Compiler | MultiCompiler; /** * watching */ watching: Watching | MultiWatching; /** * logger */ logger: Logger; /** * output file system */ outputFileSystem: OutputFileSystem; /** * hot module replacement instance */ hot?: HotInstance | undefined; /** * extension to media type, for this instance */ mimeTypes: MimeTypes;};type EXPECTED_ANY
type EXPECTED_ANY = any;type EXPECTED_FUNCTION
type EXPECTED_FUNCTION = Function;type ExtendedServerResponse
type ExtendedServerResponse = { /** * locals */ locals?: | { webpack?: { devMiddleware?: Context<IncomingMessage, ServerResponse>; }; } | undefined;};type FilenameWithExtra
type FilenameWithExtra = import('./middleware').FilenameWithExtra;type FilledContext
type FilledContext< RequestInternal extends IncomingMessage = import('node:http').IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = WithoutUndefined<Context<RequestInternal, ResponseInternal>, 'watching'>;type GetFilenameFromUrl
type GetFilenameFromUrl = (url: string) => Promise<FilenameWithExtra | undefined>;type HandleUpgrade
type HandleUpgrade = ( req: IncomingMessage, socket: import('node:stream').Duplex, head: Buffer) => boolean;type HapiOptions
type HapiOptions = Options & { compiler: Compiler | MultiCompiler;};type HapiPlugin
type HapiPlugin<S, O> = HapiPluginBase<S, O> & { pkg: { name: string; }; multiple: boolean;};type HapiPluginBase
type HapiPluginBase<S, O> = { /** * register */ register: (server: S, options: O) => void | Promise<void>;};type Headers
type Headers< RequestInternal extends IncomingMessage = import('node:http').IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = | NormalizedHeaders | (( req: RequestInternal, res: ResponseInternal, context: Context<RequestInternal, ResponseInternal> ) => void | undefined | NormalizedHeaders) | undefined;type HotInstance
type HotInstance = import('./hot').HotInstance;type HotOptions
type HotOptions = import('./hot').HotOptions;type IncomingMessage
type IncomingMessage = import('http').IncomingMessage;type Invalidate
type Invalidate = (callback: Callback) => any;type Logger
type Logger = ReturnType<Compiler['getInfrastructureLogger']>;type Middleware
type Middleware< RequestInternal extends IncomingMessage = import('node:http').IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = ( req: RequestInternal, res: ResponseInternal, next: NextFunction) => Promise<void>;type MimeOptions
type MimeOptions = { /** * register custom media types or extension mappings */ types?: | { [key: string]: string; } | undefined; /** * the media type to fall back on when the content type cannot be determined */ default?: string | undefined;};type MimeTypes
type MimeTypes = import('./utils').MimeTypes;type ModifyResponseData
type ModifyResponseData< RequestInternal extends IncomingMessage = import('node:http').IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = ( req: RequestInternal, res: ResponseInternal, data: Buffer | Readable, byteLength: number) => ResponseData;type MultiCompiler
type MultiCompiler = import('webpack').MultiCompiler;type MultiStats
type MultiStats = import('webpack').MultiStats;type MultiStatsOptions
type MultiStatsOptions = { children: Configuration['stats'][];};type MultiWatching
type MultiWatching = ReturnType<MultiCompiler['watch']>;type NextFunction
type NextFunction = (err?: EXPECTED_ANY | undefined) => void;type NormalizedHeaders
type NormalizedHeaders = | Record<string, string | number> | { key: string; value: number | string; }[];type NormalizedOptions
type NormalizedOptions< RequestInternal extends IncomingMessage = import('node:http').IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = Options<RequestInternal, ResponseInternal> & { cache: CacheOptions; mime: MimeOptions;};The options as everything below the entry point sees them: the legacy flat spellings have been folded in, so
cacheandmimeare always objects.
type OnConnect
type OnConnect = (fn: (client: EXPECTED_ANY, req: IncomingMessage) => void) => any;type Options
type Options< RequestInternal extends IncomingMessage = import('node:http').IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = { /** * how responses are cached */ cache?: CacheOptions | undefined; /** * how a file's media type is decided */ mime?: MimeOptions | undefined; /** * deprecated, use `mime.types` */ mimeTypes?: | { [key: string]: string; } | undefined; /** * deprecated, use `mime.default` */ mimeTypeDefault?: (string | undefined) | undefined; /** * write to disk */ writeToDisk?: (boolean | ((targetPath: string) => boolean)) | undefined; /** * methods */ methods?: string[] | undefined; /** * headers */ headers?: Headers<RequestInternal, ResponseInternal> | undefined; /** * public path */ publicPath?: NonNullable<Configuration['output']>['publicPath'] | undefined; /** * stats */ stats?: Configuration['stats'] | undefined; /** * is server side render */ serverSideRender?: boolean | undefined; /** * output file system */ outputFileSystem?: OutputFileSystem | undefined; /** * index */ index?: (boolean | string) | undefined; /** * modify response data */ modifyResponseData?: | ModifyResponseData<RequestInternal, ResponseInternal> | undefined; /** * deprecated, use `cache.etag` */ etag?: ('weak' | 'strong') | undefined; /** * deprecated, use `cache.lastModified` */ lastModified?: boolean | undefined; /** * deprecated, use `cache.control` */ cacheControl?: | ( | boolean | number | string | { maxAge?: number; immutable?: boolean; } ) | undefined; /** * deprecated, use `cache.immutable` */ cacheImmutable?: boolean | undefined; /** * forward error to next middleware */ forwardError?: boolean | undefined; /** * enable hot module replacement */ hot?: (boolean | HotOptions) | undefined;};type OutputFileSystem
type OutputFileSystem = import('webpack').OutputFileSystem & { createReadStream?: typeof fs.createReadStream; statSync: typeof fs.statSync; readFileSync: typeof fs.readFileSync;};type Publish
type Publish = ( payload: import('./hot').Payload | import('./hot').CustomPayload) => any;type PublishTo
type PublishTo = ( client: EXPECTED_ANY, payload: import('./hot').Payload | import('./hot').CustomPayload) => any;type Readable
type Readable = import('stream').Readable;type ReadStream
type ReadStream = import('fs').ReadStream;type ResponseData
type ResponseData = { /** * data */ data: Buffer | Readable; /** * byte length */ byteLength: number;};type Schema
type Schema = import('schema-utils/declarations/validate').Schema;type ServerResponse
type ServerResponse = import('http').ServerResponse & ExtendedServerResponse;type Stats
type Stats = import('webpack').Stats;type StatsObjectOptions
type StatsObjectOptions = Exclude< Configuration['stats'], boolean | string | undefined>;type StatsOptions
type StatsOptions = Configuration['stats'];type WaitUntilValid
type WaitUntilValid = (callback: Callback) => any;type Watching
type Watching = Compiler['watching'];type WatchOptions
type WatchOptions = NonNullable<Configuration['watchOptions']>;type WithOptional
type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<T>;type WithoutUndefined
type WithoutUndefined<T, K extends keyof T> = T & { [P in K]: NonNullable<T[P]>;};Namespaces
namespace ansi-html-community
module 'ansi-html-community' {}function ansiHtmlCommunity
ansiHtmlCommunity: typeof ansiHtmlCommunity;function setColors
setColors: (colors: Record<string, string | string[]>) => void;Package Files (2)
Dependencies (4)
Dev Dependencies (52)
- @babel/cli
- @babel/core
- @babel/preset-env
- @changesets/cli
- @changesets/get-github-info
- @fastify/express
- @hapi/hapi
- @hono/node-server
- @pmmmwh/react-refresh-webpack-plugin
- @types/connect
- @types/express
- @types/mime-db
- @types/mime-types
- @types/node
- @types/ws
- acorn
- babel-jest
- babel-loader
- babel-plugin-istanbul
- connect
- copy-webpack-plugin
- cspell
- deepmerge
- del-cli
- eslint
- eslint-config-webpack
- execa
- express
- express-4
- fastify
- file-loader
- finalhandler
- hono
- husky
- istanbul-lib-coverage
- istanbul-lib-report
- istanbul-reports
- jest
- koa
- lint-staged
- mime-types
- npm-run-all
- prettier
- puppeteer
- react
- react-dom
- react-refresh
- router
- supertest
- typescript
- webpack
- ws
Peer Dependencies (1)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/webpack-dev-middleware.
- Markdown[](https://www.jsdocs.io/package/webpack-dev-middleware)
- HTML<a href="https://www.jsdocs.io/package/webpack-dev-middleware"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2253 ms. - Missing or incorrect documentation? Open an issue for this package.
