LegacyAsyncImporter

LegacyAsyncImporter: ((this: LegacyImporterThis, url: string, prev: string, done: ((result: LegacyImporterResult) => void)) => void)

Type declaration

    • (this: LegacyImporterThis, url: string, prev: string, done: ((result: LegacyImporterResult) => void)): void
    • An asynchronous callback that implements custom Sass loading logic for @import rules and @use rules. This can be passed to importer for either render or renderSync.

      An asynchronous importer must return undefined, and then call done with the result of its LegacyImporterResult once it's done running.

      See importer for more detailed documentation.

      sass.render({
      file: "style.scss",
      importer: [
      function(url, prev, done) {
      if (url != "big-headers") done(null);

      done({
      contents: 'h1 { font-size: 40px; }'
      });
      }
      ]
      });

      Deprecated

      This only works with the legacy render and renderSync APIs. Use Importer with compile, compileString, compileAsync, and compileStringAsync instead.

      Parameters

      • this: LegacyImporterThis
      • url: string

        The @use or @import rule’s URL as a string, exactly as it appears in the stylesheet.

      • prev: string

        A string identifying the stylesheet that contained the @use or @import. This string’s format depends on how that stylesheet was loaded:

        • If the stylesheet was loaded from the filesystem, it’s the absolute path of its file.
        • If the stylesheet was loaded from an importer that returned its contents, it’s the URL of the @use or @import rule that loaded it.
        • If the stylesheet came from the data option, it’s the string "stdin".
      • done: ((result: LegacyImporterResult) => void)

        The callback to call once the importer has finished running.

      Returns void