vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.35k stars 6.16k forks source link

Inconsistent path resolution for references in HTML #17910

Open sapphi-red opened 2 months ago

sapphi-red commented 2 months ago

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

stackblitz[bot] commented 2 months ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.