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

In buildOutputOptions (build.ts:713), if an output entry has a file property set, Vite throws because it does not support rolldownOptions.output.file. Vite manages output filenames via dir + entryFileNames/chunkFileNames/assetFileNames, and a single file output conflicts with that pipeline.

Source

Thrown at packages/vite/src/node/build.ts:714

    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 89620f09af)

Solutions

  1. Remove output.file and use output.dir together with entryFileNames to control the output name.
  2. For a deterministic (non-hashed) name, set entryFileNames: '[name].js'.
  3. Keep build.outDir for the directory and let Vite compute asset/chunk names.

Example fix

// before
build: { rolldownOptions: { output: { file: 'dist/my-lib.js', format: 'es' } } }
// after
build: { outDir: 'dist', rolldownOptions: { output: { dir: 'dist', entryFileNames: 'my-lib.js', format: 'es' } } }
Defensive patterns

Strategy: validation

Validate before calling

const outputs = config.build?.rolldownOptions?.output
const arr = Array.isArray(outputs) ? outputs : outputs ? [outputs] : []
if (arr.some((o: any) => o?.file)) {
  throw new Error('rolldownOptions.output.file is not supported; use dir + entryFileNames')
}

Type guard

function usesSupportedOutput(outputs: unknown): boolean {
  const arr = Array.isArray(outputs) ? outputs : outputs ? [outputs] : []
  return !arr.some((o: any) => o?.file)
}

Prevention

When it happens

Trigger: Setting build.rolldownOptions.output.file (e.g. { file: 'dist/bundle.js' }) — typically copied from a standalone Rollup/Rolldown config.

Common situations: Porting a rollup.config.js that uses output.file into Vite's rolldownOptions; expecting single-file output behaviour.

Related errors


AI-assisted analysis of vitejs/vite@89620f09af (2026-08-03). Data as JSON: /data/errors/3229c6eae9319de8.json. Report an issue: GitHub.