vitejs/vite · error · Error
css content for ${JSON.stringify(id)} was not found
Error message
css content for ${JSON.stringify(id)} was not found What it means
Thrown during build (`renderChunk`) when a generated chunk contains a `__VITE_CSS_URL__` placeholder referencing a CSS id that is not present in the in-memory `styles` map. Vite builds that placeholder earlier (in the `load` hook for `?url` CSS) and resolves it here; a missing entry means the CSS module was never compiled or was evicted before its URL asset could be emitted.
Source
Thrown at packages/vite/src/node/plugins/css.ts:814
originalFileName: string
content: string
start: number
end: number
}> = []
if (code.includes('__VITE_CSS_URL__')) {
let match: RegExpExecArray | null
cssUrlAssetRE.lastIndex = 0
while ((match = cssUrlAssetRE.exec(code))) {
const [full, idHex] = match
const id = Buffer.from(idHex, 'hex').toString()
const originalFileName = cleanUrl(id)
const cssAssetName = ensureFileExt(
path.basename(originalFileName),
'.css',
)
if (!styles.has(id)) {
throw new Error(
`css content for ${JSON.stringify(id)} was not found`,
)
}
let cssContent = styles.get(id)!
cssContent = resolveAssetUrlsInCss(
cssContent,
cssAssetName,
originalFileName,
)
urlEmitTasks.push({
cssAssetName,
originalFileName,
content: cssContent,
start: match.index,
end: match.index + full.length,View on GitHub (pinned to 89620f09af)
Solutions
- Ensure every `*.css?url` imported file is actually processed by Vite's CSS plugin (don't intercept `*.css` in a custom plugin).
- Remove any `?url` CSS imports for files that are dynamically excluded from the build.
- Clear build cache and `node_modules/.vite`, then rebuild.
- Upgrade Vite — placeholder/`styles` map consistency bugs are fixed in patch releases.
Example fix
// before — custom plugin skips css load
{ name: 'x', load(id) { if (id.endsWith('.css')) return '' } }
// after — let vite handle css
{ name: 'x', load(id) { if (id.endsWith('.txt')) return '' } } Defensive patterns
Strategy: validation
Try / catch
try {
await build();
} catch (e) {
if (/css content .* was not found/.test(e.message)) {
console.error('A ?url CSS file was not compiled — check custom CSS plugins');
}
throw e;
} Prevention
- Do not intercept `*.css` loads in custom plugins.
- Keep `?url` CSS imports stable across the build (avoid conditional exclusion).
- Upgrade Vite to stay current with placeholder/format fixes.
When it happens
Trigger: In `renderChunk`, for each `cssUrlAssetRE` match, the hex-decoded id must exist in `styles`. If `styles.has(id)` is false, the error fires.
Common situations: Build with `?url` CSS imports combined with custom plugins that skip/short-circuit CSS compilation, CSS emitted conditionally via multiple environments, or version mismatches after upgrading Vite where the placeholder format changed.
Related errors
- When "build.cssCodeSplit: false" is set, "rolldownOptions.in
- ?url is not supported with CSS modules. (tried to import ${J
- No environment found
- Either "build.lib.entry" or the top-level "input" option is
- rolldownOptions.input should not be an html file when buildi
AI-assisted analysis of vitejs/vite@89620f09af (2026-08-03).
Data as JSON: /data/errors/4fe048d0847f3a35.json.
Report an issue: GitHub.