> ## Documentation Index
> Fetch the complete documentation index at: https://extension.js.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Fix: CRXJS "Content script fileName is undefined"

> What the CRXJS [crx:manifest-post] Content script fileName is undefined build error means, and how to fix it on current @crxjs/vite-plugin and Vite 8.

You ran `vite build` on a CRXJS extension project and got:

```text theme={null}
[crx:manifest-post] Content script fileName is undefined: "src/content.ts"
```

The build fails before the manifest is written, and the path in the error points to a file that exists in your project. Here is what it means and how to fix it.

## What the error means

`@crxjs/vite-plugin` resolves each content script to its emitted output file during the `crx:manifest-post` step (in `generateBundle`). If the plugin cannot match your content-script source to an output chunk — because of how that chunk is named or keyed — the filename comes back `undefined` and the plugin throws. It is not "your file does not exist"; it is the plugin and the bundler disagreeing about the emitted chunk for your content script.

## Is this a Vite 8 / Rolldown problem?

Mostly historical. Vite 8 switched its default bundler from Rollup to [Rolldown](https://vite.dev/blog/announcing-vite8), and CRXJS needed compatibility work for that transition (see [#1042](https://github.com/crxjs/chrome-extension-tools/pull/1042) and [#1067](https://github.com/crxjs/chrome-extension-tools/issues/1067)). That work landed: `@crxjs/vite-plugin` now supports Vite 8 ([#1132](https://github.com/crxjs/chrome-extension-tools/issues/1132)).

On current versions (`@crxjs/vite-plugin@2.7.0` with Vite 8) this error does not reproduce in common setups — including a content script that is also imported with `?script`. The original report ([#883](https://github.com/crxjs/chrome-extension-tools/issues/883)) was on Vite 5 with SolidStart/vinxi, not Rolldown.

## How to fix it

1. **Update `@crxjs/vite-plugin` to the latest release** (2.7.0 or newer), which supports Vite 8 / Rolldown:

   ```bash theme={null}
   npm install @crxjs/vite-plugin@latest --save-dev
   ```

2. **Check how the manifest references the script.** Use a root-relative path that matches your project, and confirm the same file is not also imported elsewhere with a `?script` suffix (double-registration is the most common remaining edge case).

3. **If you cannot upgrade yet,** pinning `vite@^7` (still Rollup-based) is a temporary unblock until you can move to a current `@crxjs/vite-plugin`.

If you still hit this on current versions, the maintainers are responsive — open an issue with a minimal reproduction at [crxjs/chrome-extension-tools](https://github.com/crxjs/chrome-extension-tools/issues).
