initAsyncCompiler
- init
Async Compiler():Promise<AsyncCompiler> - Dart Sass
- since 1.70.0
- Node Sass
- ✗
Compatibility:Creates an asynchronousAsyncCompiler. Each compilerinstance exposes thecompileAsync andcompileStringAsyncmethods within the lifespan of the Compiler. Given identical input, thesemethods will return results identical to their counterparts exposed at themodule root. To use synchronous compilation, useinitCompiler;
When calling the compile functions multiple times, using a compiler instancewith thesass-embedded npm package is much faster than using the top-levelcompilation methods or thesass npm package.
Example
constsass =require('sass');
asyncfunctionsetup() {
constcompiler =awaitsass.initAsyncCompiler();
constresult1 =awaitcompiler.compileStringAsync('a {b: c}').css;
constresult2 =awaitcompiler.compileStringAsync('a {b: c}').css;
awaitcompiler.dispose();
// throws error
constresult3 =awaitsass.compileStringAsync('a {b: c}').css;
}ReturnsPromise<AsyncCompiler>
- Defined injs-api-doc/compile.d.ts:342