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

  1. Delete the output.file key; Vite derives the filename from outDir + entryFileNames.
  2. For a library, use build.lib.fileName to control the single output name instead of output.file.
  3. 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

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


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)