AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Turbopack Asset Rule For CSS Query Url Fails In Server Components

When configuring Turbopack rules to treat `.css?url` imports as asset type, importing from a Server Component fails with 'css client asset is not css chunk placeable'. The same configuration works from Client Components and for other asset types like SVG.

highConfidence 95%Next.jsAffected V16.3.8Affected V16.4.0-Canary.57

Origin Analysis

In the RSC context, every `.css` file is intercepted by `NextCssClientReferenceTransition` before user-defined Turbopack rules are evaluated. This transition matches solely on the file path suffix `.css` and expects the module to be `CssChunkPlaceable`. When a user rule changes the module type to `asset`, the module is no longer `CssChunkPlaceable`, causing the build to fail.
1. Create `next.config.ts` with `turbopack.rules` mapping `*.css` with query `url` to type `asset`. 2. In a Server Component (e.g., `app/layout.tsx`), import `stylesUrl from './styles.css?url'` and use it in a `<link>` tag. 3. Run `next dev` or `next build`. 4. Observe the error `Module not found: Can't resolve './styles.css' ... css client asset is not css chunk placeable`.

Fixing Code Block

Edge Case Audit

This workaround disables content hashing and cache busting for the stylesheet; manual cache invalidation (e.g., adding a version query parameter) is required when the file changes. It also assumes the CSS is static and does not require processing (e.g., autoprefixing, minification). For production, the proper fix is to upgrade to a Next.js version that skips the CSS transition when a user rule sets a non-CSS type, or conditionally matches on the import query. Rollback is straightforward: remove the public file and revert the import to `./styles.css?url`.

Ecosystem Topology