Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vite can not import css file as url #5130

Closed
7 tasks done
Inori-Lover opened this issue Sep 29, 2021 · 4 comments
Closed
7 tasks done

vite can not import css file as url #5130

Inori-Lover opened this issue Sep 29, 2021 · 4 comments

Comments

@Inori-Lover
Copy link

Describe the bug

import css file as url will become something like this:

export default "/src/components/test.css"

while import js\png\svg with same grammar return the path right.

Reproduction

https://github.com/Inori-Lover/vite-can-not-import-css-as-url

System Info

System:
    OS: Windows 10 10.0.19042
    CPU: (12) x64 Intel(R) Core(TM) i7-10710U CPU @ 1.10GHz
    Memory: 3.52 GB / 15.81 GB
  Binaries:
    Node: 14.17.6 - C:\Program Files\nodejs\node.EXE       
    Yarn: 1.22.11 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.14.15 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1023.0), Chromium (94.0.992.31)
    Internet Explorer: 11.0.19041.1202
  npmPackages:
    @vitejs/plugin-vue: ^1.9.0 => 1.9.2 
    vite: ^2.5.10 => 2.5.10

Used Package Manager

npm

Logs

/

Validations

@jacksteamdev
Copy link

I want this for a plugin I'm building, but it's a bit tricky. I understand why #5229 was closed.

In production, the CSS from imported components is bundled into a single stylesheet. What is the URL for each import? Are they all the same? If you're creating a link tag for each one, you'll end up with a bunch of duplicates.

In development, CSS imports are converted to a JS file to support HMR. URL imports for CSS would make this more complicated, and break CSS HMR for a URL import, forcing a full reload.

We likely need something else, or should just support this on the entry file.

@bluwy
Copy link
Member

bluwy commented Mar 15, 2022

Maybe related #2522

@jacksteamdev
Copy link

@bluwy Thanks, this seems to be the definitive comment: #2522 (comment)

@sapphi-red
Copy link
Member

I think this could be closed by #5796 via #5940.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants