Interface FileImporter<sync>
Type parameters
sync: "sync" | "async" = "sync" | "async"
A
FileImporter<'sync'>
's findFileUrl must return synchronously, but in return it can be passed to compile and compileString in addition to compileAsync and compileStringAsync.A
FileImporter<'async'>
's findFileUrl may either return synchronously or asynchronously, but it can only be used with compileAsync and compileStringAsync.
Hierarchy
- FileImporter
Index
Methods
Methods
find File Url
Unlike an Importer, the compiler will automatically handle relative loads for a FileImporter. See Options.importers for more details on the way loads are resolved.
Parameters
url: string
The loaded URL. Since this might be relative, it's represented as a string rather than a [[URL]] object.
options: { fromImport: boolean }
from
Import: boolean Whether this is being invoked because of a Sass
@import
rule, as opposed to a@use
or@forward
rule.This should only be used for determining whether or not to load import-only files.
Returns PromiseOr<null | URL, sync>
An absolute
file:
URL if this importer recognizes theurl
. This may be only partially resolved: the compiler will automatically look for partials, index files, and file extensions based on the returned URL. An importer may also return a fully resolved URL if it so chooses.If this importer doesn't recognize the URL, it should return
null
instead to allow other importers or load paths to handle it.This may also return a
Promise
, but if it does the importer may only be passed to compileAsync and compileStringAsync, not compile or compileString.
A special type of importer that redirects all loads to existing files on disk. Although this is less powerful than a full Importer, it automatically takes care of Sass features like resolving partials and file extensions and of loading the file from disk.
Like all importers, this implements custom Sass loading logic for
@use
rules and@import
rules. It can be passed to Options.importers or StringOptionsWithImporter.importer.