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

Can't access this.options.file in custom functions of sass.compile #2290

Closed
itchyny opened this issue Jul 27, 2024 · 2 comments
Closed

Can't access this.options.file in custom functions of sass.compile #2290

itchyny opened this issue Jul 27, 2024 · 2 comments

Comments

@itchyny
Copy link

itchyny commented Jul 27, 2024

While sass.render allows us to access the compile context with this.options. Especially this.options.file is useful for modifying the value of url() to be relative from the output css file. However, sass.compile invokes custom functions with null context, and I cannot tell the context being processed. This prevents me to migrate from the legacy render APIs. Related issue: #1233.

@nex3
Copy link
Contributor

nex3 commented Jul 27, 2024

This is intentional. Providing unconditional access to the base file's URL makes it easy for an importer to violate canonicity requirements, so it's specifically only provided in canonicalizeContext and only for importers that meet certain restrictions. If you're looking to do URL rewriting, I recommend following along with sass/sass#2535.

@nex3 nex3 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 27, 2024
@itchyny
Copy link
Author

itchyny commented Jul 27, 2024

Yes, I'm looking for a way to rewrite URL, so I read through sass/sass#2535. The proposal sass.url.relativeToCss seems fit to my use case. I'll wait for the feature to be implemented (watching sass/sass#2927). Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants