mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
feat(vite): introduce vite:configResolved
hook (#20411)
This commit is contained in:
parent
fac160c79f
commit
17ca50354b
@ -71,6 +71,7 @@ Hook | Arguments | Description
|
|||||||
`schema:written` | - | Called after the schema is written.
|
`schema:written` | - | Called after the schema is written.
|
||||||
`vite:extend` | `viteBuildContext` | Allows to extend Vite default context.
|
`vite:extend` | `viteBuildContext` | Allows to extend Vite default context.
|
||||||
`vite:extendConfig` | `viteInlineConfig, env` | Allows to extend Vite default config.
|
`vite:extendConfig` | `viteInlineConfig, env` | Allows to extend Vite default config.
|
||||||
|
`vite:configResolved` | `viteInlineConfig, env` | Allows to read the resolved Vite config.
|
||||||
`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.
|
||||||
|
@ -290,6 +290,13 @@ export interface NuxtHooks {
|
|||||||
* @returns Promise
|
* @returns Promise
|
||||||
*/
|
*/
|
||||||
'vite:extendConfig': (viteInlineConfig: ViteConfig, env: { isClient: boolean, isServer: boolean }) => HookResult
|
'vite:extendConfig': (viteInlineConfig: ViteConfig, env: { isClient: boolean, isServer: boolean }) => HookResult
|
||||||
|
/**
|
||||||
|
* Allows to read the resolved Vite config.
|
||||||
|
* @param viteInlineConfig The vite inline config object
|
||||||
|
* @param env Server or client
|
||||||
|
* @returns Promise
|
||||||
|
*/
|
||||||
|
'vite:configResolved': (viteInlineConfig: Readonly<ViteConfig>, env: { isClient: boolean, isServer: boolean }) => HookResult
|
||||||
/**
|
/**
|
||||||
* Called when the Vite server is created.
|
* Called when the Vite server is created.
|
||||||
* @param viteServer Vite development server
|
* @param viteServer Vite development server
|
||||||
|
@ -127,6 +127,8 @@ export async function buildClient (ctx: ViteBuildContext) {
|
|||||||
viteJsxPlugin(clientConfig.vueJsx)
|
viteJsxPlugin(clientConfig.vueJsx)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await ctx.nuxt.callHook('vite:configResolved', clientConfig, { isClient: true, isServer: false })
|
||||||
|
|
||||||
if (ctx.nuxt.options.dev) {
|
if (ctx.nuxt.options.dev) {
|
||||||
// Dev
|
// Dev
|
||||||
const viteServer = await vite.createServer(clientConfig)
|
const viteServer = await vite.createServer(clientConfig)
|
||||||
|
@ -148,6 +148,8 @@ export async function buildServer (ctx: ViteBuildContext) {
|
|||||||
viteJsxPlugin(serverConfig.vueJsx)
|
viteJsxPlugin(serverConfig.vueJsx)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await ctx.nuxt.callHook('vite:configResolved', serverConfig, { isClient: false, isServer: true })
|
||||||
|
|
||||||
const onBuild = () => ctx.nuxt.callHook('vite:compiled')
|
const onBuild = () => ctx.nuxt.callHook('vite:compiled')
|
||||||
|
|
||||||
// Production build
|
// Production build
|
||||||
|
Loading…
Reference in New Issue
Block a user