W3cubDocs

/Sass

compileAsync

  • Compatibility:
    Dart Sass
    since 1.45.0
    Node Sass

    Asynchronously compiles the Sass file at path to CSS. Returns a promise that resolves with a CompileResult if it succeeds and rejects with an Exception if it fails.

    This only allows synchronous or asynchronous Importers and CustomFunctions.

    When using the sass npm package, compile is almost twice as fast as compileAsync, due to the overhead of making the entire evaluation process asynchronous.

    Example

    constsass = require('sass');

    constresult = awaitsass.compileAsync("style.scss");
    console.log(result.css);

    Parameters

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

    Returns Promise<CompileResult>

© 2006–2025 the Sass team, and numerous contributors
Licensed under the MIT License.
https://sass-lang.com/documentation/js-api/functions/compileAsync