Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
feat(kit): support client and server flags for addVitePlugin (#5560)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Jun 22, 2022
1 parent 2156079 commit 3081489
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/kit/src/build.ts
Expand Up @@ -15,9 +15,6 @@ export interface ExtendConfigOptions {
* @default true
*/
build?: boolean
}

export interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
/**
* Install plugin on server side
*
Expand All @@ -30,6 +27,9 @@ export interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
* @default true
*/
client?: boolean
}

export interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
/**
* Install plugin on modern build
*
Expand Down Expand Up @@ -99,7 +99,14 @@ export function extendViteConfig (
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)
}
})
}

/**
Expand Down

0 comments on commit 3081489

Please sign in to comment.