compileAsync

  • Kompatibilität
    Dart Sass
    seit 1.45.0
    Node Sass

    Kompiliert die Sass-Datei unter path asynchron zu CSS. Gibt ein Promise zurück, das bei Erfolg mit einem CompileResult aufgelöst wird und bei Fehlschlag mit einer Exception abgelehnt wird.

    Dies erlaubt nur synchrone oder asynchrone Importer und CustomFunctions.

    ⚠️ Vorsicht!

    Wenn Sie das npm-Paket sass verwenden, ist compile fast doppelt so schnell wie compileAsync, aufgrund des Overheads, den gesamten Evaluierungsprozess asynchron zu gestalten.

    Beispiel

    const sass = require('sass');

    const result = await sass.compileAsync("style.scss");
    console.log(result.css);

    Parameter

    • path: string
    • Optional options: Options<"async">

    Gibt Promise<CompileResult> zurück