From 8b9d6bb36483fd8fb18a9d57e3e46f6947b37719 Mon Sep 17 00:00:00 2001 From: Jon Bockhorst Date: Mon, 12 Jan 2026 22:51:24 -0600 Subject: [PATCH] Handle css quotes when collecting dev styles --- e2e/react-start/css-modules/src/styles/global.css | 5 +++++ e2e/solid-start/css-modules/src/styles/global.css | 5 +++++ e2e/vue-start/css-modules/src/styles/global.css | 5 +++++ .../start-plugin-core/src/dev-server-plugin/dev-styles.ts | 7 ++++--- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/e2e/react-start/css-modules/src/styles/global.css b/e2e/react-start/css-modules/src/styles/global.css index 5bef746780e..5d35c81d2a9 100644 --- a/e2e/react-start/css-modules/src/styles/global.css +++ b/e2e/react-start/css-modules/src/styles/global.css @@ -1,5 +1,10 @@ /* Global styles for testing CSS collection in dev mode */ +.global-container:before { + content: ' '; + content: " "; +} + .global-container { background-color: #3b82f6; /* blue-500 */ padding: 24px; diff --git a/e2e/solid-start/css-modules/src/styles/global.css b/e2e/solid-start/css-modules/src/styles/global.css index 5bef746780e..5d35c81d2a9 100644 --- a/e2e/solid-start/css-modules/src/styles/global.css +++ b/e2e/solid-start/css-modules/src/styles/global.css @@ -1,5 +1,10 @@ /* Global styles for testing CSS collection in dev mode */ +.global-container:before { + content: ' '; + content: " "; +} + .global-container { background-color: #3b82f6; /* blue-500 */ padding: 24px; diff --git a/e2e/vue-start/css-modules/src/styles/global.css b/e2e/vue-start/css-modules/src/styles/global.css index 5bef746780e..5d35c81d2a9 100644 --- a/e2e/vue-start/css-modules/src/styles/global.css +++ b/e2e/vue-start/css-modules/src/styles/global.css @@ -1,5 +1,10 @@ /* Global styles for testing CSS collection in dev mode */ +.global-container:before { + content: ' '; + content: " "; +} + .global-container { background-color: #3b82f6; /* blue-500 */ padding: 24px; diff --git a/packages/start-plugin-core/src/dev-server-plugin/dev-styles.ts b/packages/start-plugin-core/src/dev-server-plugin/dev-styles.ts index e3d09439152..5505967564d 100644 --- a/packages/start-plugin-core/src/dev-server-plugin/dev-styles.ts +++ b/packages/start-plugin-core/src/dev-server-plugin/dev-styles.ts @@ -20,7 +20,8 @@ export function normalizeCssModuleCacheKey(idOrFile: string): string { // URL params that indicate CSS should not be injected (e.g., ?url, ?inline) const CSS_SIDE_EFFECT_FREE_PARAMS = ['url', 'inline', 'raw', 'inline-css'] -const VITE_CSS_REGEX = /const\s+__vite__css\s*=\s*["'`]([\s\S]*?)["'`]/ +const VITE_CSS_REGEX = + /const\s+__vite__css\s*=\s*(["'`])((?:\\[\s\S]|(?!\1)[\s\S])*)\1/ const ESCAPE_CSS_COMMENT_START_REGEX = /\/\*/g const ESCAPE_CSS_COMMENT_END_REGEX = /\*\//g @@ -250,9 +251,9 @@ async function fetchCssFromModule( function extractCssFromCode(code: string): string | undefined { const match = VITE_CSS_REGEX.exec(code) - if (!match?.[1]) return undefined + if (!match?.[2]) return undefined - return match[1] + return match[2] .replace(/\\n/g, '\n') .replace(/\\t/g, '\t') .replace(/\\"/g, '"')