compileStringAsync

  • Kompatibilität
    Dart Sass
    seit 1.45.0
    Node Sass

    Kompiliert einen Stylesheet, dessen Inhalt source ist, asynchron zu CSS. Gibt ein Promise zurück, das bei Erfolg mit einem CompileResult aufgelöst und bei Fehler mit einer Exception abgelehnt wird.

    Dies erlaubt nur synchrone oder asynchrone Importer und CustomFunctions.

    ⚠️ Vorsicht!

    Bei Verwendung des sass npm-Pakets ist compileString fast doppelt so schnell wie compileStringAsync, aufgrund des Overheads, der durch die asynchrone Verarbeitung des gesamten Auswertungsprozesses entsteht.

    Beispiel

    const sass = require('sass');

    const result = await sass.compileStringAsync(`
    h1 {
    font-size: 40px;
    code {
    font-face: Roboto Mono;
    }
    }`);
    console.log(result.css);

    Parameter

    Gibt Promise<CompileResult> zurück