Build fails if <script> src path doesn't start with a slash #7818
Labels
feat: html
has workaround
inconsistency
Inconsistency between dev & build
p2-nice-to-have
Not breaking anything but nice to have (priority)
Describe the bug
If you move files into an
assets
folder or any other kind of structure, you must refer tomain.js
as/assets/main.js
. Though, CSS and favicon can be referred as justassets/main.css
andassets/favicon.svg
.The issue is that Vite throws this:
But it actually "works" on
npm run dev
and the script is loaded by the browser as expected. But if you donpm run build
, it throws:I wonder if this inconsistency happens because Rollup looks into project folder instead of index.html location.
Reproduction
https://stackblitz.com/edit/vitejs-vite-jchmw5?file=index.html&terminal=dev
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: