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'm importing sass from a package (govuk-frontend) which has a mixin to generate asset URLs.
When using the modern Sass API with Vite, and using an alias in the import path, I find that the assets don't build and I get an error message $govuk-fonts-path + $filename referenced in $govuk-fonts-path + $filename didn't resolve at build time, it will remain unchanged to be resolved at runtime.
When debugging, I can see that the rebaseUrls function is converting the url($govuk-fonts-path + $filename) from the mixin into url("$govuk-fonts-path + $filename"). This is unexpected, because the variables should be replaced with their values before the rebaseUrls function wraps them in quotes.
This doesn't happen if the package is imported using another importer:
The package is imported using Sass's NodePackageImporter and the pkg: syntax
The package is imported using its full node_modules URL (i.e. node_modules/govuk-frontend/dist/govuk/all) which I think must use Sass's builtin FileImporter
It alsl doesn't happen when using the legacy Sass API. This suggests to me that there's something different happening in makeModernScssWorker’s internalImporter that causes rebaseUrls to be run before the sass variables have been resolved.
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'm importing sass from a package (govuk-frontend) which has a mixin to generate asset URLs.
When using the modern Sass API with Vite, and using an alias in the import path, I find that the assets don't build and I get an error message
$govuk-fonts-path + $filename referenced in $govuk-fonts-path + $filename didn't resolve at build time, it will remain unchanged to be resolved at runtime
.When debugging, I can see that the rebaseUrls function is converting the
url($govuk-fonts-path + $filename)
from the mixin intourl("$govuk-fonts-path + $filename")
. This is unexpected, because the variables should be replaced with their values before the rebaseUrls function wraps them in quotes.This doesn't happen if the package is imported using another importer:
NodePackageImporter
and thepkg:
syntaxnode_modules/govuk-frontend/dist/govuk/all
) which I think must use Sass's builtin FileImporterIt alsl doesn't happen when using the legacy Sass API. This suggests to me that there's something different happening in
makeModernScssWorker
’sinternalImporter
that causes rebaseUrls to be run before the sass variables have been resolved.Reproduction
https://github.com/DavidBiddle/vite-issue-test
Steps to reproduce
Run
npm install
andnpx vite build
Check response for
didn't resolve at build time, it will remain unchanged to be resolved at runtime
messageSystem Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: