LegacyAsyncImporter

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

類型宣告

    • (this: LegacyImporterThis, url: 字串, prev: 字串, done: ((result: LegacyImporterResult) => void)): void
    • 這是一個非同步回呼函式,它實作了針對 @import 規則@use 規則 的客製 Sass 載入邏輯。它可以作為 importer 參數傳遞給 renderrenderSync

      非同步 importer 必須回傳 undefined,然後在其 LegacyImporterResult 執行完成後,呼叫 done 並傳入結果。

      更多詳細文件,請參閱 importer

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

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

      已棄用 (Deprecated)

      這僅適用於舊版 renderrenderSync API。請改用 Importer 搭配 compilecompileStringcompileAsynccompileStringAsync

      參數

      • this: LegacyImporterThis
      • url: string

        @use@import 規則的網址字串,與其在樣式表中出現的樣子完全相同。

      • prev: string

        用於識別包含 @use@import 規則的樣式表的字串。此字串的格式取決於該樣式表的載入方式。

        • 如果樣式表是從檔案系統載入的,則此字串為其檔案的絕對路徑。
        • 如果樣式表是從回傳其內容的 importer 載入的,則此字串為載入它的 @use@import 規則的網址。
        • 如果樣式表來自 data 選項,則此字串為 "stdin"。
      • done: ((result: LegacyImporterResult) => void)

        importer 執行完成後要呼叫的回呼函式。

      回傳 void