vitejs/vite · error · Error
Vite does not support "rolldownOptions.output.file". Please…
Error message
Vite does not support "rolldownOptions.output.file". Please use "rolldownOptions.output.dir" and "rolldownOptions.output.entryFileNames" instead.
What it means
Vite post-processes output, so it forbids the rolldownOptions.output.file option that Rollup/Rolldown use to write a single bundle to an absolute filename. The check runs inside buildOutputOptions and instructs users to use dir plus entryFileNames instead, which Vite already fills in for you.
Solutions
- Delete the output.file key; Vite derives the filename from outDir + entryFileNames.
- For a library, use build.lib.fileName to control the single output name instead of output.file.
- To pin a custom name, set build.rolldownOptions.output.entryFileNames (e.g. 'my-lib.js').
Example fix
// before
build: {
rollupOptions: { output: { file: 'dist/bundle.js', format: 'es' } }
}
// after
build: {
rollupOptions: { output: { dir: 'dist', entryFileNames: 'bundle.js', format: 'es' } }
} Defensive patterns
Strategy: validation
Validate before calling
function stripOutputFile(rollupOptions) {
if (rollupOptions?.output?.file) {
const { file, ...rest } = rollupOptions.output;
return { ...rollupOptions, output: { ...rest, dir: rest.dir || 'dist', entryFileNames: file } };
}
return rollupOptions;
} Type guard
function outputHasNoFile(rollupOptions) {
const out = Array.isArray(rollupOptions?.output) ? rollupOptions.output[0] : rollupOptions?.output;
return !out || !('file' in out);
} Prevention
- Never carry output.file over from a Rollup config; Vite owns output naming.
- Use build.lib.fileName for library single-file output instead of output.file.
When it happens
Trigger: Passing output.file (e.g. { file: 'dist/bundle.js' }) inside build.rolldownOptions.output. Common when porting a raw Rollup config into Vite.
Common situations: Developers migrating from rollup.config.js or copying examples from Rollup docs. Library authors who expect a single output file.
Related errors
- When "build.cssCodeSplit: false" is set…
- Environment " " is not defined in the config.
- `input` cannot contain glob characters. They are reserved…
- Multiple entry points are not supported when output formats…
- Name in package.json is required if option…
AI-assisted analysis of vitejs/vite@b4d66fee14 (2026-08-11).
Data as JSON: /api/errors/3229c6eae9319de8.
Report an issue: GitHub.
Appendix: source
Thrown at packages/vite/src/node/build.ts:718
environment.getTopLevelConfig().ssr?.target === 'webworker'
// For webworker SSR with platform: 'browser', external CJS require() calls
// need to be converted to ESM imports since createRequire is not available.
if (isSsrTargetWebworkerEnvironment) {
plugins.push(esmExternalRequirePlugin())
}
const buildOutputOptions = (output: OutputOptions = {}): OutputOptions => {
// @ts-expect-error See https://github.com/vitejs/vite/issues/5812#issuecomment-984345618
if (output.output) {
logger.warn(
`You've set "rolldownOptions.output.output" in your config. ` +
`This is deprecated and will override all Vite.js default output options. ` +
`Please use "rolldownOptions.output" instead.`,
)
}
if (output.file) {
throw new Error(
`Vite does not support "rolldownOptions.output.file". ` +
`Please use "rolldownOptions.output.dir" and "rolldownOptions.output.entryFileNames" instead.`,
)
}
if (output.sourcemap) {
logger.warnOnce(
colors.yellow(
`Vite does not support "rolldownOptions.output.sourcemap". ` +
`Please use "build.sourcemap" instead.`,
),
)
}
const format = output.format || 'es'
const jsExt =
(ssr && !isSsrTargetWebworkerEnvironment) || libOptions
? resolveOutputJsExtension(
format,View on GitHub (pinned to b4d66fee14)