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.jsfromsrc/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.jsexists. -
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.jsin Pug and adding Eleventy transforms to rewrite aliases — messy and fragile. -
Removed
rollupOptions.inputto rely on Vite root — dev works but production build fails (same error). -
Cleaned
.11ty-viteand_sitebetween runs.
Questions / request
-
Has anyone else seen Vite 7 /
@11ty/eleventy-plugin-vitebecome stricter about resolving script src paths in.11ty-vite/*/index.htmlduring build? -
Is the correct pattern for Eleventy + Vite (production) to:
-
reference the script as
/app/index.jsin templates and add that file explicitly tobuild.rollupOptions.input, or -
keep
root: "src"and use a Vite alias (e.g.@app/index.js) in HTML and let Vite rewrite it somehow?
-
-
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!