Inconsistent path resolution for references in HTML #17910
Open
Description
Describe the bug
The following cases doesn't work in dev, but works in build:
<script type="module" src="@/main.js"></script> <!-- alias that doesn't start with / -->
<script type="module" src="C:/absolute/path/to/main.js"></script> <!-- absolute path on Windows 1 -->
<script type="module" src="C:\absolute\path\to\main.js"></script> <!-- absolute path on Windows 2 -->
Reproduction
https://stackblitz.com/edit/vitejs-vite-bdueaz?file=vite.config.js,index.html&terminal=dev (for the first case)
Steps to reproduce
No response
System Info
System:
OS: Windows 11 10.0.22631
CPU: (16) x64 13th Gen Intel(R) Core(TM) i7-1360P
Memory: 16.99 GB / 31.62 GB
Binaries:
Node: 20.16.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
npm: 10.8.1 - C:\Program Files\nodejs\npm.CMD
bun: 1.1.21 - ~\AppData\Local\Microsoft\WinGet\Links\bun.EXE
Browsers:
Edge: Chromium (127.0.2651.74)
Internet Explorer: 11.0.22621.3527
npmPackages:
vite: ^5.4.2 => 5.4.2
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.