webpack-dev-middleware

  • Version 8.3.0
  • Published
  • 269 kB
  • 5 dependencies
  • MIT license

Install

npm i webpack-dev-middleware
yarn add webpack-dev-middleware
pnpm add webpack-dev-middleware

Overview

A development middleware for webpack

Index

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;
  • {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} 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;
  • {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} kow 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;
/**
* 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 Callback

      type Callback = (stats?: (Stats | MultiStats) | undefined) => any;

        type Close

        type Close = (callback: (err: Error | null | undefined) => void) => any;

          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
              */
              options: Options<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;
              };

                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 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 ModifyResponseData

                                                type ModifyResponseData<
                                                RequestInternal extends IncomingMessage = import('node:http').IncomingMessage,
                                                ResponseInternal extends ServerResponse = ServerResponse
                                                > = (
                                                req: RequestInternal,
                                                res: ResponseInternal,
                                                data: Buffer | ReadStream,
                                                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 Options

                                                              type Options<
                                                              RequestInternal extends IncomingMessage = import('node:http').IncomingMessage,
                                                              ResponseInternal extends ServerResponse = ServerResponse
                                                              > = {
                                                              /**
                                                              * mime types
                                                              */
                                                              mimeTypes?:
                                                              | {
                                                              [key: string]: string;
                                                              }
                                                              | undefined;
                                                              /**
                                                              * mime type 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;
                                                              /**
                                                              * options to generate etag header
                                                              */
                                                              etag?: ('weak' | 'strong') | undefined;
                                                              /**
                                                              * options to generate last modified header
                                                              */
                                                              lastModified?: boolean | undefined;
                                                              /**
                                                              * options to generate cache headers
                                                              */
                                                              cacheControl?:
                                                              | (
                                                              | boolean
                                                              | number
                                                              | string
                                                              | {
                                                              maxAge?: number;
                                                              immutable?: boolean;
                                                              }
                                                              )
                                                              | undefined;
                                                              /**
                                                              * is 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 ReadStream

                                                                  type ReadStream = import('fs').ReadStream;

                                                                    type ResponseData

                                                                    type ResponseData = {
                                                                    /**
                                                                    * data
                                                                    */
                                                                    data: Buffer | ReadStream;
                                                                    /**
                                                                    * 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 (5)

                                                                                                Dev Dependencies (43)

                                                                                                Peer Dependencies (1)

                                                                                                Badge

                                                                                                To add a badge like this onejsDocs.io badgeto 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
                                                                                                  [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](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>