mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
feat(webpack): introduce webpack:configResolved
hook (#20412)
This commit is contained in:
parent
17ca50354b
commit
cd7f38988a
@ -75,6 +75,7 @@ Hook | Arguments | Description
|
|||||||
`vite:serverCreated` | `viteServer, env` | Called when the Vite server is created.
|
`vite:serverCreated` | `viteServer, env` | Called when the Vite server is created.
|
||||||
`vite:compiled` | - | Called after Vite server is compiled.
|
`vite:compiled` | - | Called after Vite server is compiled.
|
||||||
`webpack:config` | `webpackConfigs` | Called before configuring the webpack compiler.
|
`webpack:config` | `webpackConfigs` | Called before configuring the webpack compiler.
|
||||||
|
`webpack:configResolved` | `webpackConfigs` | Allows to read the resolved webpack config.
|
||||||
`webpack:compile` | `options` | Called right before compilation.
|
`webpack:compile` | `options` | Called right before compilation.
|
||||||
`webpack:compiled` | `options` | Called after resources are loaded.
|
`webpack:compiled` | `options` | Called after resources are loaded.
|
||||||
`webpack:change` | `shortPath` | Called on `change` on WebpackBar.
|
`webpack:change` | `shortPath` | Called on `change` on WebpackBar.
|
||||||
|
@ -317,6 +317,12 @@ export interface NuxtHooks {
|
|||||||
* @returns Promise
|
* @returns Promise
|
||||||
*/
|
*/
|
||||||
'webpack:config': (webpackConfigs: Configuration[]) => HookResult
|
'webpack:config': (webpackConfigs: Configuration[]) => HookResult
|
||||||
|
/**
|
||||||
|
* Allows to read the resolved webpack config
|
||||||
|
* @param webpackConfigs Configs objects to be pushed to the compiler
|
||||||
|
* @returns Promise
|
||||||
|
*/
|
||||||
|
'webpack:configResolved': (webpackConfigs: Readonly<Configuration>[]) => HookResult
|
||||||
/**
|
/**
|
||||||
* Called right before compilation.
|
* Called right before compilation.
|
||||||
* @param options The options to be added
|
* @param options The options to be added
|
||||||
|
@ -35,8 +35,7 @@ export async function bundle (nuxt: Nuxt) {
|
|||||||
// Initialize shared MFS for dev
|
// Initialize shared MFS for dev
|
||||||
const mfs = nuxt.options.dev ? createMFS() : null
|
const mfs = nuxt.options.dev ? createMFS() : null
|
||||||
|
|
||||||
// Configure compilers
|
for (const config of webpackConfigs) {
|
||||||
const compilers = webpackConfigs.map((config) => {
|
|
||||||
config.plugins!.push(DynamicBasePlugin.webpack({
|
config.plugins!.push(DynamicBasePlugin.webpack({
|
||||||
sourcemap: nuxt.options.sourcemap[config.name as 'client' | 'server']
|
sourcemap: nuxt.options.sourcemap[config.name as 'client' | 'server']
|
||||||
}))
|
}))
|
||||||
@ -49,7 +48,12 @@ export async function bundle (nuxt: Nuxt) {
|
|||||||
rootDir: nuxt.options.rootDir,
|
rootDir: nuxt.options.rootDir,
|
||||||
composables: nuxt.options.optimization.keyedComposables
|
composables: nuxt.options.optimization.keyedComposables
|
||||||
}))
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
await nuxt.callHook('webpack:configResolved', webpackConfigs)
|
||||||
|
|
||||||
|
// Configure compilers
|
||||||
|
const compilers = webpackConfigs.map((config) => {
|
||||||
// Create compiler
|
// Create compiler
|
||||||
const compiler = webpack(config)
|
const compiler = webpack(config)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user