Skip to content

Define a standard for custom URL loaders #2535

@nex3

Description

@nex3

Many CSS features involve referring to assets outside the stylesheet using URLs: plain CSS @imports, background images, and so on. It's not always obvious how these assets will map to URLs on the server, though. Currently Sass provides no built-in support for this mapping, but doing so would be very useful.

I think Sass implementations should expose the ability for users to define their own URL-resolution logic that's invoked for every url() and every plain-CSS @import. This should be done through a JS API that's shared between Dart Sass and Node Sass, as well as a Dart API for Dart Sass users who invoke it via Dart.

I also think it would be valuable to provide some built-in resolution strategies that are available via the command line and through JS/Dart as standardized resolvers. For example, we might want to provide the ability to resolve URLs to data: URLs that embed the document directly, or to map directories on the filesystem to URLs that will be served.

Metadata

Metadata

Assignees

No one assigned

    Labels

    JS APIAbout the shared JS APIenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions