From 60746c7fc2b90120dd64766c0545d4d2e5244a9c Mon Sep 17 00:00:00 2001 From: wangkehan Date: Sat, 13 Jan 2024 10:18:40 +0800 Subject: [PATCH] dynmaic SSR env Dynamically setting env.SSR enables the framework to use different logic codes in SSR and CSR --- src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 0231bd8..5a2e0a2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,7 +10,9 @@ const VitePluginConditionalCompile = (userOptions: UserOptions = {}): Plugin => configResolved(config) { ctx.env = { ...ctx.env, ...config.env } }, - transform: (code, id) => ctx.transform(code, id), + transform: (code, id, SSR) => { + ctx.env.SSR = SSR + return ctx.transform(code, id) } }