vite build
rejects new URL(url, import.meta.url)
with template strings that don't begin with /
or ./
#10032
Open
7 tasks done
Labels
Describe the bug
When running
vite dev
and visiting the site, all of the following methods of resolving assets work:However, when running
vite build
, the third case (new URL(`pets/${species}.txt`, import.meta.url)
) causes the build to fail with the messageIt seems a bit inconsistent that static relative URLs without a leading
./
work but not dynamic ones. Ideally, all four should work.I understand that the JavaScript spec require relative module imports to begin with a leading
./
, but this is just a URL to a generic asset.path/to/asset
and./path/to/asset
should be equivalent.Reproduction
https://stackblitz.com/edit/vitejs-vite-9ymymw
System Info
System: OS: Linux 5.0 undefined CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 0 Bytes / 0 Bytes Shell: 1.0 - /bin/jsh Binaries: Node: 16.14.2 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 7.17.0 - /usr/local/bin/npm npmPackages: vite: ^3.1.0 => 3.1.0
Used Package Manager
npm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: