feat(kit): support client and server flags for `addVitePlugin` (#5560)

This commit is contained in:
Daniel Roe 2022-06-22 18:29:51 +01:00 committed by GitHub
parent 2156079405
commit 308148977d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 4 deletions

View File

@ -15,9 +15,6 @@ export interface ExtendConfigOptions {
* @default true * @default true
*/ */
build?: boolean build?: boolean
}
export interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
/** /**
* Install plugin on server side * Install plugin on server side
* *
@ -30,6 +27,9 @@ export interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
* @default true * @default true
*/ */
client?: boolean client?: boolean
}
export interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
/** /**
* Install plugin on modern build * Install plugin on modern build
* *
@ -99,7 +99,14 @@ export function extendViteConfig (
return return
} }
nuxt.hook('vite:extend', ({ config }) => fn(config)) nuxt.hook('vite:extendConfig', (config, { isClient, isServer }) => {
if (options.server !== false && isServer) {
return fn(config)
}
if (options.client !== false && isClient) {
return fn(config)
}
})
} }
/** /**