webpack-dev-middleware

  • Version 7.2.1
  • Published
  • 112 kB
  • 6 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
>() => HapiPlugin<HapiServer, HapiOptionsInternal>;
  • HapiServer {HapiOptions} HapiOptionsInternal

    Returns

    {HapiPlugin<HapiServer, HapiOptionsInternal>}

function koaWrapper

koaWrapper: <
RequestInternal extends any = any,
ResponseInternal extends unknown = any
>(
compiler: Compiler | MultiCompiler,
options?: Options<RequestInternal, ResponseInternal> | undefined
) => (ctx: any, next: Function) => Promise<void> | void;
  • {IncomingMessage} [RequestInternal=IncomingMessage] {ServerResponse} [ResponseInternal=ServerResponse]

    Parameter compiler

    Parameter options

    Returns

    {(ctx: any, next: Function) => Promise | void}

function wdm

wdm: typeof wdm;
  • {IncomingMessage} [RequestInternal=IncomingMessage] {ServerResponse} [ResponseInternal=ServerResponse]

    Parameter compiler

    Parameter options

    Returns

    {API<RequestInternal, ResponseInternal>}

Type Aliases

type AdditionalMethods

type AdditionalMethods<
RequestInternal extends import('http').IncomingMessage,
ResponseInternal extends ServerResponse
> = {
getFilenameFromUrl: GetFilenameFromUrl;
waitUntilValid: WaitUntilValid;
invalidate: Invalidate;
close: Close;
context: Context<RequestInternal, ResponseInternal>;
};

    type API

    type API<
    RequestInternal extends import('http').IncomingMessage = import('http').IncomingMessage,
    ResponseInternal extends ServerResponse = ServerResponse
    > = Middleware<RequestInternal, ResponseInternal> &
    AdditionalMethods<RequestInternal, ResponseInternal>;

      type Callback

      type Callback = (
      stats?: import('webpack').Stats | import('webpack').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 import('http').IncomingMessage = import('http').IncomingMessage,
              ResponseInternal extends ServerResponse = ServerResponse
              > = {
              state: boolean;
              stats: Stats | MultiStats | undefined;
              callbacks: Callback[];
              options: Options<RequestInternal, ResponseInternal>;
              compiler: Compiler | MultiCompiler;
              watching: Watching | MultiWatching | undefined;
              logger: Logger;
              outputFileSystem: OutputFileSystem;
              };

                type ExtendedServerResponse

                type ExtendedServerResponse = {
                locals?:
                | {
                webpack?:
                | {
                devMiddleware?:
                | Context<import('http').IncomingMessage, ServerResponse>
                | undefined;
                }
                | undefined;
                }
                | undefined;
                };

                  type Extra

                  type Extra = import('./utils/getFilenameFromUrl').Extra;

                    type FilledContext

                    type FilledContext<
                    RequestInternal extends import('http').IncomingMessage = import('http').IncomingMessage,
                    ResponseInternal extends ServerResponse = ServerResponse
                    > = WithoutUndefined<Context<RequestInternal, ResponseInternal>, 'watching'>;

                      type GetFilenameFromUrl

                      type GetFilenameFromUrl = (
                      url: string,
                      extra?: Extra | undefined
                      ) => string | undefined;

                        type HapiOptions

                        type HapiOptions = Options & {
                        compiler: Compiler | MultiCompiler;
                        };

                          type HapiPlugin

                          type HapiPlugin<S, O> = HapiPluginBase<S, O> & {
                          pkg: {
                          name: string;
                          };
                          };

                            type HapiPluginBase

                            type HapiPluginBase<S, O> = {
                            register: (server: S, options: O) => void | Promise<void>;
                            };

                              type Headers

                              type Headers<
                              RequestInternal extends import('http').IncomingMessage = import('http').IncomingMessage,
                              ResponseInternal extends ServerResponse = ServerResponse
                              > =
                              | NormalizedHeaders
                              | ((
                              req: RequestInternal,
                              res: ResponseInternal,
                              context: Context<RequestInternal, ResponseInternal>
                              ) => void | undefined | NormalizedHeaders)
                              | undefined;

                                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 import('http').IncomingMessage = import('http').IncomingMessage,
                                      ResponseInternal extends ServerResponse = ServerResponse
                                      > = (
                                      req: RequestInternal,
                                      res: ResponseInternal,
                                      next: NextFunction
                                      ) => Promise<void>;

                                        type ModifyResponseData

                                        type ModifyResponseData<
                                        RequestInternal extends import('http').IncomingMessage = import('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 MultiWatching

                                              type MultiWatching = ReturnType<MultiCompiler['watch']>;

                                                type NextFunction

                                                type NextFunction = (err?: any) => void;

                                                  type NormalizedHeaders

                                                  type NormalizedHeaders =
                                                  | Record<string, string | number>
                                                  | Array<{
                                                  key: string;
                                                  value: number | string;
                                                  }>;

                                                    type Options

                                                    type Options<
                                                    RequestInternal extends import('http').IncomingMessage = import('http').IncomingMessage,
                                                    ResponseInternal extends ServerResponse = ServerResponse
                                                    > = {
                                                    mimeTypes?:
                                                    | {
                                                    [key: string]: string;
                                                    }
                                                    | undefined;
                                                    mimeTypeDefault?: string | undefined;
                                                    writeToDisk?: boolean | ((targetPath: string) => boolean) | undefined;
                                                    methods?: string[] | undefined;
                                                    headers?: Headers<RequestInternal, ResponseInternal>;
                                                    publicPath?: NonNullable<Configuration['output']>['publicPath'];
                                                    stats?: Configuration['stats'];
                                                    serverSideRender?: boolean | undefined;
                                                    outputFileSystem?: OutputFileSystem | undefined;
                                                    index?: string | boolean | undefined;
                                                    modifyResponseData?:
                                                    | ModifyResponseData<RequestInternal, ResponseInternal>
                                                    | undefined;
                                                    etag?: 'strong' | 'weak' | undefined;
                                                    lastModified?: boolean | undefined;
                                                    };

                                                      type OutputFileSystem

                                                      type OutputFileSystem = Object & {
                                                      createReadStream?: typeof import('fs').createReadStream;
                                                      statSync?: import('fs').StatSyncFn;
                                                      lstat?: typeof import('fs').lstat;
                                                      readFileSync?: typeof import('fs').readFileSync;
                                                      };

                                                        type ReadStream

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

                                                          type ResponseData

                                                          type ResponseData = {
                                                          data: Buffer | ReadStream;
                                                          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 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]>;
                                                                          };

                                                                            Package Files (1)

                                                                            Dependencies (6)

                                                                            Dev Dependencies (40)

                                                                            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>