Build fails cant upload to vercel — Vite can’t resolve /app/index.js

Hi — I upgraded some dev deps (sass, vite 7.x, @11ty/eleventy-plugin-vite, etc.) and my Eleventy + Vite build now fails only during production build and dev. Dev server runs but in production Vite throws cant upload to vercel:

Project layout (relevant):

project-root/
  src/
    app/
      index.js         ← exists (8750 bytes)
      components/
      pages/
    views/             ← Eleventy Pug templates live here
  .eleventy.js
  package.json

What I’m using (relevant deps):

  • vite 7.1.7

  • @11ty/eleventy-plugin-vite ^7.0.0

  • @11ty/eleventy ^3.1.2

  • sass updated recently
    (others available on request)

Key part of my .eleventy.js vite options:

EleventyVitePlugin, {
  tempFolderName: ".11ty-vite",
  viteOptions: {
    root: "src",
    publicDir: "public",
    build: {
      emptyOutDir: false,
      // I previously had rollupOptions.input here; removed/added during debugging
    },
    resolve: {
      alias: {
        "@app": path.resolve(process.cwd(), "src/app"),
        // ...
      }
    }
  }
}

What I see

  • Eleventy generates .11ty-vite/<page>/index.html (these files contain <script type="module" src="/app/index.js">).

  • Vite’s build step (the plugin) tries to transform those HTML files and fails to resolve /app/index.js.

  • Dev server: when I serve with eleventy --serve + plugin, the browser previously could load /app/index.js from src/app/index.js, but now I get pre-transform errors in dev too unless I fiddle with input/aliases.

What I’ve tried

  • Confirmed src/app/index.js exists.

  • Tried adding rollupOptions.input: { main: path.resolve(process.cwd(), "src/app/index.js") } (fixes dev in some combos but still errors during build).

  • Tried using @app/index.js in Pug and adding Eleventy transforms to rewrite aliases — messy and fragile.

  • Removed rollupOptions.input to rely on Vite root — dev works but production build fails (same error).

  • Cleaned .11ty-vite and _site between runs.

Questions / request

  1. Has anyone else seen Vite 7 / @11ty/eleventy-plugin-vite become stricter about resolving script src paths in .11ty-vite/*/index.html during build?

  2. Is the correct pattern for Eleventy + Vite (production) to:

    • reference the script as /app/index.js in templates and add that file explicitly to build.rollupOptions.input, or

    • keep root: "src" and use a Vite alias (e.g. @app/index.js) in HTML and let Vite rewrite it somehow?

  3. Any recommended, robust config example (minimal .eleventy.js + Pug snippet) that works for both dev and prod with Vite 7 + @11ty/eleventy-plugin-vite?

If helpful I can post my full .eleventy.js, the generated .11ty-vite/about/index.html contents, and the exact index.js entry. Thanks!

When you say “cant upload to vercel”, how are you trying to deploy? Are you deploying via CLI and getting failures? If so, can you share the exact command and error message?

The last four deploys I see in your project were successful but those were before you posted this message

Yup, working however for it to work I have to use “@appapp/index.j path is the script otherwise it won’t work but in dev its a 404 can find the index.js

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.