From d9f49f72a15ae624d87f28add42bdea4e786980c Mon Sep 17 00:00:00 2001 From: endigma Date: Wed, 21 Dec 2022 10:34:51 -0400 Subject: [PATCH 1/3] vite-plugin: Whitelist `vite-plugin-svelte` and make `forceEmitCssiInSsrBuild` configurable. --- .changeset/rotten-days-help.md | 5 +++++ packages/vite-plugin/src/index.ts | 15 +++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 .changeset/rotten-days-help.md diff --git a/.changeset/rotten-days-help.md b/.changeset/rotten-days-help.md new file mode 100644 index 000000000..a2d06167d --- /dev/null +++ b/.changeset/rotten-days-help.md @@ -0,0 +1,5 @@ +--- +'@vanilla-extract/vite-plugin': minor +--- + +Whitelist `vite-plugin-svelte` and make `forceEmitCssiInSsrBuild` configurable. diff --git a/packages/vite-plugin/src/index.ts b/packages/vite-plugin/src/index.ts index 21195e75d..6422953b0 100644 --- a/packages/vite-plugin/src/index.ts +++ b/packages/vite-plugin/src/index.ts @@ -22,10 +22,13 @@ const virtualExtJs = '.vanilla.js'; interface Options { identifiers?: IdentifierOption; + forceSSREmit?: boolean; esbuildOptions?: CompileOptions['esbuildOptions']; } + export function vanillaExtractPlugin({ identifiers, + forceSSREmit, esbuildOptions, }: Options = {}): Plugin { let config: ResolvedConfig; @@ -33,7 +36,8 @@ export function vanillaExtractPlugin({ let postCssConfig: PostCSSConfigResult | null; const cssMap = new Map(); - let forceEmitCssInSsrBuild: boolean = !!process.env.VITE_RSC_BUILD; + let forceEmitCssInSsrBuild: boolean = + !!process.env.VITE_RSC_BUILD || !!forceSSREmit; let packageName: string; const getAbsoluteVirtualFileId = (source: string) => @@ -70,9 +74,12 @@ export function vanillaExtractPlugin({ if ( config.plugins.some((plugin) => - ['astro:build', 'solid-start-server', 'vite-plugin-qwik'].includes( - plugin.name, - ), + [ + 'astro:build', + 'solid-start-server', + 'vite-plugin-qwik', + 'vite-plugin-svelte', + ].includes(plugin.name), ) ) { forceEmitCssInSsrBuild = true; From 66e79e6b6e69125590f40c885d7bb2f88a503593 Mon Sep 17 00:00:00 2001 From: Michael Taranto Date: Mon, 23 Jan 2023 11:59:36 +1100 Subject: [PATCH 2/3] Rolling back the forceSSREmit flag We will look at adding this flag along with documentation in a separate PR. --- packages/vite-plugin/src/index.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/vite-plugin/src/index.ts b/packages/vite-plugin/src/index.ts index 6422953b0..b87c24408 100644 --- a/packages/vite-plugin/src/index.ts +++ b/packages/vite-plugin/src/index.ts @@ -22,13 +22,10 @@ const virtualExtJs = '.vanilla.js'; interface Options { identifiers?: IdentifierOption; - forceSSREmit?: boolean; esbuildOptions?: CompileOptions['esbuildOptions']; } - export function vanillaExtractPlugin({ identifiers, - forceSSREmit, esbuildOptions, }: Options = {}): Plugin { let config: ResolvedConfig; @@ -36,8 +33,7 @@ export function vanillaExtractPlugin({ let postCssConfig: PostCSSConfigResult | null; const cssMap = new Map(); - let forceEmitCssInSsrBuild: boolean = - !!process.env.VITE_RSC_BUILD || !!forceSSREmit; + let forceEmitCssInSsrBuild: boolean = !!process.env.VITE_RSC_BUILD; let packageName: string; const getAbsoluteVirtualFileId = (source: string) => From 15870391930d32c5d7881c52ed97e20d2c1ab969 Mon Sep 17 00:00:00 2001 From: Michael Taranto Date: Mon, 23 Jan 2023 12:01:15 +1100 Subject: [PATCH 3/3] Update rotten-days-help.md --- .changeset/rotten-days-help.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/rotten-days-help.md b/.changeset/rotten-days-help.md index a2d06167d..9d6986e17 100644 --- a/.changeset/rotten-days-help.md +++ b/.changeset/rotten-days-help.md @@ -1,5 +1,5 @@ --- -'@vanilla-extract/vite-plugin': minor +'@vanilla-extract/vite-plugin': patch --- -Whitelist `vite-plugin-svelte` and make `forceEmitCssiInSsrBuild` configurable. +Whitelist `vite-plugin-svelte` to enable emitting CSS on the server