From 308148977d5d7e29ad3e6e6ecfda54a3d4a56e8a Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 22 Jun 2022 18:29:51 +0100 Subject: [PATCH] feat(kit): support client and server flags for `addVitePlugin` (#5560) --- packages/kit/src/build.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/kit/src/build.ts b/packages/kit/src/build.ts index ee220e3b21d..320cea821ce 100644 --- a/packages/kit/src/build.ts +++ b/packages/kit/src/build.ts @@ -15,9 +15,6 @@ export interface ExtendConfigOptions { * @default true */ build?: boolean -} - -export interface ExtendWebpackConfigOptions extends ExtendConfigOptions { /** * Install plugin on server side * @@ -30,6 +27,9 @@ export interface ExtendWebpackConfigOptions extends ExtendConfigOptions { * @default true */ client?: boolean +} + +export interface ExtendWebpackConfigOptions extends ExtendConfigOptions { /** * Install plugin on modern build * @@ -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) + } + }) } /**