{"record":{"id":"024c234125b5156b","repo":"vitejs/vite","slug":"when-build-csscodesplit-false-is-set-rolldown","errorCode":null,"errorMessage":"When \"build.cssCodeSplit: false\" is set, \"rolldownOptions.input\" should not include CSS files.","messagePattern":"When \"build\\.cssCodeSplit: false\" is set, \"rolldownOptions\\.input\" should not include CSS files\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vite/src/node/build.ts","lineNumber":641,"sourceCode":"      ? resolve(options.ssr)\n      : options.rolldownOptions.input ||\n        (topLevelInput ?? resolve('index.html'))\n\n  if (ssr && typeof input === 'string' && input.endsWith('.html')) {\n    throw new Error(\n      `rolldownOptions.input should not be an html file when building for SSR. ` +\n        `Please specify a dedicated SSR entry.`,\n    )\n  }\n  if (options.cssCodeSplit === false) {\n    const inputs =\n      typeof input === 'string'\n        ? [input]\n        : Array.isArray(input)\n          ? input\n          : Object.values(input)\n    if (inputs.some((input) => input.endsWith('.css'))) {\n      throw new Error(\n        `When \"build.cssCodeSplit: false\" is set, \"rolldownOptions.input\" should not include CSS files.`,\n      )\n    }\n  }\n\n  const outDir = resolve(options.outDir)\n\n  // inject environment and ssr arg to plugin load/transform hooks\n  const plugins = environment.plugins.map((p) =>\n    injectEnvironmentToHooks(environment, chunkMetadataMap, p),\n  )\n\n  const rolldownOptions: RolldownOptions = {\n    preserveEntrySignatures: ssr\n      ? 'allow-extension'\n      : libOptions\n        ? 'strict'\n        : false,","sourceCodeStart":623,"sourceCodeEnd":659,"githubUrl":"https://github.com/vitejs/vite/blob/b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab/packages/vite/src/node/build.ts#L623-L659","documentation":"Thrown when build.cssCodeSplit is disabled (false) yet one of the rolldownOptions.input entries points at a .css file. With cssCodeSplit off, Vite feeds CSS through the JS pipeline (moduleType '.css': 'js'), so a raw CSS entry produces an invalid JS module. The guard lives in build.ts where inputs are flattened from string/array/object forms before bundling.","triggerScenarios":"Setting build.cssCodeSplit: false in vite.config while also listing a .css file under build.rolldownOptions.input (string, array, or object form). Happens most often when migrating an HTML-driven build to a CSS-only entry.","commonSituations":"Design-system or component-library builds that want a single bundled stylesheet and accidentally pass the .css path as the build entry instead of the .ts/.js source. Also seen when copy-pasting rolldownOptions.input from a pure-CSS pipeline.","solutions":["Point rolldownOptions.input at the JS/TS entry that imports the CSS, not at the .css file directly.","If you truly need a standalone CSS bundle, leave cssCodeSplit at its default (true) and import the stylesheet from JS so Vite extracts it.","Remove the .css path from input and instead import it from your entry module."],"exampleFix":"// before\nbuild: {\n  cssCodeSplit: false,\n  rollupOptions: { input: 'src/styles.css' }\n}\n// after\nbuild: {\n  cssCodeSplit: false,\n  rollupOptions: { input: 'src/entry.ts' } // entry.ts imports './styles.css'\n}","handlingStrategy":"validation","validationCode":"function validateInput(input, cssCodeSplit) {\n  if (!cssCodeSplit) {\n    const inputs = Array.isArray(input) ? input\n      : typeof input === 'object' ? Object.values(input) : [input];\n    if (inputs.some((i) => String(i).endsWith('.css'))) {\n      return { ok: false, reason: 'input must not contain .css when cssCodeSplit is false' };\n    }\n  }\n  return { ok: true };\n}","typeGuard":"function isNonCssInput(input) {\n  const inputs = Array.isArray(input) ? input\n    : typeof input === 'object' && input !== null ? Object.values(input) : [input];\n  return inputs.every((i) => !String(i).endsWith('.css'));\n}","tryCatchPattern":null,"preventionTips":["Always point build.rolldownOptions.input at JS/TS source files that import CSS, never at raw .css files.","Audit rolldownOptions.input whenever you toggle build.cssCodeSplit."],"tags":["build","css","config","rolldown"],"backgroundTag":null,"analyzedSha":"b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab","analyzedAt":"2026-08-11T11:49:19.515Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}