{"id":"4fe048d0847f3a35","repo":"vitejs/vite","slug":"css-content-for-json-stringify-id-was-not-foun","errorCode":null,"errorMessage":"css content for ${JSON.stringify(id)} was not found","messagePattern":"css content for (.+?) was not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vite/src/node/plugins/css.ts","lineNumber":814,"sourceCode":"              originalFileName: string\n              content: string\n              start: number\n              end: number\n            }> = []\n\n            if (code.includes('__VITE_CSS_URL__')) {\n              let match: RegExpExecArray | null\n              cssUrlAssetRE.lastIndex = 0\n              while ((match = cssUrlAssetRE.exec(code))) {\n                const [full, idHex] = match\n                const id = Buffer.from(idHex, 'hex').toString()\n                const originalFileName = cleanUrl(id)\n                const cssAssetName = ensureFileExt(\n                  path.basename(originalFileName),\n                  '.css',\n                )\n                if (!styles.has(id)) {\n                  throw new Error(\n                    `css content for ${JSON.stringify(id)} was not found`,\n                  )\n                }\n\n                let cssContent = styles.get(id)!\n\n                cssContent = resolveAssetUrlsInCss(\n                  cssContent,\n                  cssAssetName,\n                  originalFileName,\n                )\n\n                urlEmitTasks.push({\n                  cssAssetName,\n                  originalFileName,\n                  content: cssContent,\n                  start: match.index,\n                  end: match.index + full.length,","sourceCodeStart":796,"sourceCodeEnd":832,"githubUrl":"https://github.com/vitejs/vite/blob/89620f09afcfef6b35e7bb8660132ab5b4d0cd3b/packages/vite/src/node/plugins/css.ts#L796-L832","documentation":"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.","triggerScenarios":"In `renderChunk`, for each `cssUrlAssetRE` match, the hex-decoded id must exist in `styles`. If `styles.has(id)` is false, the error fires.","commonSituations":"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.","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."],"exampleFix":"// before — custom plugin skips css load\n{ name: 'x', load(id) { if (id.endsWith('.css')) return '' } }\n// after — let vite handle css\n{ name: 'x', load(id) { if (id.endsWith('.txt')) return '' } }","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await build();\n} catch (e) {\n  if (/css content .* was not found/.test(e.message)) {\n    console.error('A ?url CSS file was not compiled — check custom CSS plugins');\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["css","build","url-import","asset"],"analyzedSha":"89620f09afcfef6b35e7bb8660132ab5b4d0cd3b","analyzedAt":"2026-08-03T19:28:02.920Z","schemaVersion":2}