withastro/astro · warning

Unable to find CSS for ${routeData.component}. This is likel

Error message

Unable to find CSS for ${routeData.component}. This is likely a bug in Astro.

What it means

In the dev server's app environment, per-route framework styles are resolved by looking up the route component inside the virtual module virtual:astro:dev-css-all and importing its css collection. If the dev-CSS map has no entry for that component, Astro logs this 'assets' warning — self-described as likely an Astro bug — and renders the page with an empty style set, so framework CSS is missing in dev.

Source

Thrown at packages/astro/src/vite-plugin-app/environment.ts:221

						});
					} else if (script.stage === 'page' && isPage(filePath, settings)) {
						scripts.add({
							props: { type: 'module', src: `/@id/${PAGE_SCRIPT_ID}` },
							children: '',
						});
					}
				}
			}

			const { devCSSMap } = await import('virtual:astro:dev-css-all');

			const importer = devCSSMap.get(routeData.component);
			let css = new Set<ImportedDevStyle>();
			if (importer) {
				const cssModule = await importer();
				css = cssModule.css;
			} else {
				getLogger(manifest).warn(
					'assets',
					`Unable to find CSS for ${routeData.component}. This is likely a bug in Astro.`,
				);
			}

			// Pass framework CSS in as style tags to be appended to the page.
			const links = new Set<SSRElement>();

			const styles = new Set<SSRElement>();
			for (const { id, url: src, content } of css) {
				// Vite handles HMR for styles injected as scripts
				scripts.add({ props: { type: 'module', src }, children: '' });
				// But we still want to inject the styles to avoid FOUC. The style tags
				// should emulate what Vite injects so further HMR works as expected.
				styles.add({ props: { 'data-vite-dev-id': id }, children: content });
			}

			return { scripts, styles, links };

View on GitHub (pinned to 52e6c34790)

Solutions

  1. Restart the dev server so virtual:astro:dev-css-all regenerates
  2. Delete cache directories (node_modules/.astro and node_modules/.vite) and start dev again
  3. Verify no custom integration injects routes in a way that bypasses the dev-CSS plugin
  4. If it reproduces from a clean install, open an Astro issue with a minimal repro — the message itself says it is likely a bug
Defensive patterns

Strategy: retry

Prevention

When it happens

Trigger: Running `astro dev` when the generated dev-css map is stale or incomplete relative to the route graph: after adding/removing a framework island, renaming pages, integration-injected routes, or an Astro version regression that fails to populate the virtual module.

Common situations: Styles present in `astro build` output but missing in dev; appears right after upgrading Astro or a framework integration; monorepos with custom route-injecting integrations whose components never get registered in the map.

Related errors


AI-assisted analysis of withastro/astro@52e6c34790 (2026-08-18). Data as JSON: /api/errors/82ba20d1694a72ba. Report an issue: GitHub.