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

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

Merged
merged 2 commits into from
Jun 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions packages/kit/src/build.ts
Original file line number Diff line number Diff line change
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