diff options
| -rw-r--r-- | .changeset/smooth-hats-smell.md | 5 | ||||
| -rw-r--r-- | packages/astro/src/core/render/dev/css.ts | 7 | 
2 files changed, 10 insertions, 2 deletions
| diff --git a/.changeset/smooth-hats-smell.md b/.changeset/smooth-hats-smell.md new file mode 100644 index 000000000..cac2f8bef --- /dev/null +++ b/.changeset/smooth-hats-smell.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Ensure SSR module is loaded before testing if it's CSS in dev diff --git a/packages/astro/src/core/render/dev/css.ts b/packages/astro/src/core/render/dev/css.ts index cfbfa7114..9c10cb03c 100644 --- a/packages/astro/src/core/render/dev/css.ts +++ b/packages/astro/src/core/render/dev/css.ts @@ -18,11 +18,14 @@ export async function getStylesForURL(  	for await (const importedModule of crawlGraph(viteServer, viteID(filePath), true)) {  		const ext = path.extname(importedModule.url).toLowerCase();  		if (STYLE_EXTENSIONS.has(ext)) { +			// The SSR module is possibly not loaded. Load it if it's null. +			const ssrModule = +				importedModule.ssrModule ?? (await viteServer.ssrLoadModule(importedModule.url));  			if (  				mode === 'development' && // only inline in development -				typeof importedModule.ssrModule?.default === 'string' // ignore JS module styles +				typeof ssrModule?.default === 'string' // ignore JS module styles  			) { -				importedStylesMap.set(importedModule.url, importedModule.ssrModule.default); +				importedStylesMap.set(importedModule.url, ssrModule.default);  			} else {  				// NOTE: We use the `url` property here. `id` would break Windows.  				importedCssUrls.add(importedModule.url); | 
