-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
fix(css): @import with .css in node_modules importing a different package failed to resolve #15000
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tried yet, but IIUC this rebaseUrl
function only rewrites @import
with css extension. The issue is about @import
with less extension. Does this work?
Also would you add a test?
Hi @sapphi-red, I have tested this fix by linking vite against the failing case https://stackblitz.com/edit/vite-sass-transitive-import?file=src%2Fstyle.scss in #12227 and now the file can be correctly resolved. The less version should work the same. I have tried to write a test case for that, but it seems the issue only happens for npm instead of pnpm package manager. I can't make the test case fail without this fix. |
I see. It seems #9681 and #12227 is caused by a different reason. I mistakenly said #12227 is a duplicate.
I guess it would fail if you use |
Hi @sapphi-red a test cases is added with your method to use file instead of link. Can we merge this soon? Thanks! There are some flaky tests on node-20, macos-latest however it passes on my development mac |
Description
fixes #12227
refs #9681
Additional context
The cause of the bug is when performing sass style preprocessing, it's trying to rewrite the @import lines in the code using sass render with internalImporter.
The internalImporter resolve the url and then tries to perform a rebase of the url. The rebaseUrls is not correctly performing rebase if we try to perform another import from a different package.
So instead of calling path.resolve, we have to try the corresponding resolver first with id and importer.
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).