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 1 commit
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
Next Next commit
feat(kit): support client/server flags for addVitePlugin
  • Loading branch information
danielroe committed Jun 22, 2022
commit 66cf1915576089aab5e4f97afd9710937b1d31c1
21 changes: 20 additions & 1 deletion packages/kit/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ export interface ExtendConfigOptions {
* @default true
*/
build?: boolean
/**
* Install plugin on server side
*
* @default true
*/
server?: boolean
/**
* Install plugin on client side
*
* @default true
*/
client?: boolean
}

export interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
Expand Down Expand Up @@ -99,7 +111,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