You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Vite.js application where I import an SCSS file from a dependency. In a CSS bundle produce by Vite, the path is incorrect and invalid.
This issue seems to be specific to the file structure, as I can reproduce it if the SCSS file name matches the target directory name except the leading underscore and the url() argument is built using a variable:
In the resulting bundle, the foobar/static.png relative path is rebased to become .../xxx/_foobar.scssstatic.png (see the reproduction repo).
In the real life scenario, although we do control the said dependency, changes to its file structure constitute a breaking change for our customers, that is why it's important for us that this issue is addressed.
This issue may look a bit similar to the existing scss path rebase issues, both fixed and active (#11012, #19058), but I believe it may be a separate problem given that the open issues do not mention distorted file paths.
npm run build to build a barebone app in packages/client-app
Open the build output at packages/client-app/dist/assets/index-XXX.css
Search for the url() function and notice its argument. Vite rebased the foobar/react.png relative path so that it became invalid: ../../scss-dep/src/_foobar.scssreact.png
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.
Describe the bug
I have a Vite.js application where I import an SCSS file from a dependency. In a CSS bundle produce by Vite, the path is incorrect and invalid.
This issue seems to be specific to the file structure, as I can reproduce it if the SCSS file name matches the target directory name except the leading underscore and the
url()
argument is built using a variable:In the resulting bundle, the
foobar/static.png
relative path is rebased to become.../xxx/_foobar.scssstatic.png
(see the reproduction repo).In the real life scenario, although we do control the said dependency, changes to its file structure constitute a breaking change for our customers, that is why it's important for us that this issue is addressed.
This issue may look a bit similar to the existing scss path rebase issues, both fixed and active (#11012, #19058), but I believe it may be a separate problem given that the open issues do not mention distorted file paths.
Reproduction
https://github.com/VasilyStrelyaev/vite-scss-path-rebase-repro
Steps to reproduce
npm install
npm run build
to build a barebone app inpackages/client-app
packages/client-app/dist/assets/index-XXX.css
url()
function and notice its argument. Vite rebased thefoobar/react.png
relative path so that it became invalid:../../scss-dep/src/_foobar.scssreact.png
System Info
System: OS: macOS 15.4 CPU: (8) arm64 Apple M1 Pro Memory: 499.88 MB / 32.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 22.14.0 - /usr/local/bin/node Yarn: 1.22.22 - ~/.yarn/bin/yarn npm: 11.2.0 - /usr/local/bin/npm pnpm: 9.15.4 - /usr/local/bin/pnpm Browsers: Chrome: 135.0.7049.42 Edge: 135.0.3179.54 Safari: 18.4
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: