compile

  • compile(path:string,options?:Options<"sync">):CompileResult
  • Compatibility:
    Dart Sass
    since 1.45.0
    Node Sass

    Synchronously compiles the Sass file atpath toCSS. If it succeeds itreturns aCompileResult, and if it fails it throws anException.

    This only allows synchronousImporters andCustomFunctions.

    ⚠️ Heads up!

    When using thesass-embedded npm package for singlecompilations,compileAsync is almost always faster thancompile, due to the overhead of emulating synchronous messagingwith worker threads and concurrent compilations being blocked on main thread.

    If you are running multiple compilations with thesass-embedded npmpackage, using aCompiler will provide some speed improvements overthe module-level methods, and anAsyncCompiler will be much faster.

    Example

    constsass =require('sass');

    constresult =sass.compile("style.scss");
    console.log(result.css);

    Parameters

    • path:string
    • Optionaloptions:Options<"sync">

    ReturnsCompileResult