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

Aliases are not resolved for CSS URLs with fragments #17690

Closed
7 tasks done
CyberAP opened this issue Jul 16, 2024 · 1 comment · Fixed by #17691
Closed
7 tasks done

Aliases are not resolved for CSS URLs with fragments #17690

CyberAP opened this issue Jul 16, 2024 · 1 comment · Fixed by #17691

Comments

@CyberAP
Copy link
Contributor

CyberAP commented Jul 16, 2024

Describe the bug

If you use URL fragments (url('foo#bar')) inside CSS they will not be resolved using aliases from Vite config.

Reproduction

https://stackblitz.com/edit/vitejs-vite-k7ay22?file=style.css

Steps to reproduce

  1. Create an alias to an SVG sprite.
  2. Reference one of the SVG sprites using that alias in CSS, example: background: url('my.svg#some-image')
  3. Import should be resolved using the defined alias

When using reproduction link:

  1. Inspect the first block (#fragment)
  2. Remove the fragment from the source code (#test)
  3. Notice how the background URL changes from url(fragment.svg#test) to url('/folder/fragment.svg')

System Info

System:
    OS: macOS 14.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 163.20 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.asdf/installs/nodejs/20.12.2/bin/node
    Yarn: 1.22.19 - ~/.asdf/shims/yarn
    npm: 10.5.0 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Chrome: 126.0.6478.127
    Chrome Canary: 128.0.6598.0
    Firefox: 127.0
    Safari: 17.5
    Safari Technology Preview: 18.0
  npmPackages:
    @vitejs/plugin-vue2: ^2.3.1 => 2.3.1 
    vite: ^5.3.3 => 5.3.3

Used Package Manager

yarn

Logs

No response

Validations

Copy link

stackblitz bot commented Jul 16, 2024

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

CyberAP pushed a commit to CyberAP/vite that referenced this issue Jul 16, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 9, 2024
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.

1 participant