feat(webpack): add webpack:devMiddleware and webpack:hotMiddleware hooks (#3606)

This commit is contained in:
Ahad Birang 2022-03-13 22:13:41 +03:30 committed by GitHub
parent a068e00451
commit e891ea0cca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

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

View File

@ -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]) {