diff --git a/packages/schema/src/types/hooks.ts b/packages/schema/src/types/hooks.ts index a2336996aa..f0d8dd70ad 100644 --- a/packages/schema/src/types/hooks.ts +++ b/packages/schema/src/types/hooks.ts @@ -143,6 +143,8 @@ export interface NuxtHooks { // @nuxt/webpack 'webpack:config': (webpackConfigs: Configuration[]) => HookResult + 'webpack:devMiddleware': (middleware: (req: IncomingMessage, res: ServerResponse, next: (err?: any) => any) => any) => HookResult + 'webpack:hotMiddleware': (middleware: (req: IncomingMessage, res: ServerResponse, next: (err?: any) => any) => any) => HookResult 'build:compile': (options: { name: string, compiler: Compiler }) => HookResult 'build:compiled': (options: { name: string, compiler: Compiler, stats: Stats }) => HookResult 'build:resources': (mfs?: Compiler['outputFileSystem']) => HookResult diff --git a/packages/webpack/src/webpack.ts b/packages/webpack/src/webpack.ts index 154e9bd15c..01de8b5259 100644 --- a/packages/webpack/src/webpack.ts +++ b/packages/webpack/src/webpack.ts @@ -89,6 +89,9 @@ async function createDevMiddleware (compiler: Compiler) { ...hotMiddlewareOptions })) + await nuxt.callHook('webpack:devMiddleware', devMiddleware) + await nuxt.callHook('webpack:hotMiddleware', hotMiddleware) + // Register devMiddleware on server await nuxt.callHook('server:devMiddleware', async (req, res, next) => { for (const mw of [devMiddleware, hotMiddleware]) {