vitejs / vite

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

support preload and prefetch of css #11486

Open Officialstrike opened 1 year ago

Officialstrike commented 1 year ago

Describe the bug

Vite does not currently support the use of preload and prefetch tags for CSS files, despite the benefits of using these values. It seems they are removed when built, this is mainly due to vite splitting up assets into assets and stylesheet references, with the stylesheet references only the URL is kept, most of the time if there is a preload tag there is a stylesheet tag in the head, which means there are duplicate URLs and are eventually eliminated.

Reproduction

https://stackblitz.com/edit/vitejs-vite-t1esnp?file=index.html

Steps to reproduce

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (12) x64 Intel(R) Core(TM) i7-8086K CPU @ 4.00GHz
    Memory: 5.35 GB / 31.93 GB
  Binaries:
    Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 3.3.0 - C:\Program Files\nodejs\yarn.CMD
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0)
  npmPackages:
    vite: ^4.0.3 => 4.0.3

It didn't detect the browser, but my browser is the latest firefox version (108.01).

Used Package Manager

npm

Logs

No response

Validations

TheElegantCoding commented 1 year ago

this is so necessary i am so surprise the time vite takes to do this