compileStringAsync
- compile
String Async(source:string,options?:StringOptions<"async">):Promise<CompileResult> - Dart Sass
- since 1.45.0
- Node Sass
- ✗
Compatibility:Asynchronously compiles a stylesheet whose contents is
source
toCSS.Returns a promise that resolves with aCompileResult if it succeedsand rejects with anException if it fails.This only allows synchronous or asynchronousImporters andCustomFunctions.
⚠️ Heads up!
When using the
sass
npm package,compileString isalmost twice as fast ascompileStringAsync, due to the overheadof making the entire evaluation process asynchronous.Example
constsass =require('sass');
constresult =awaitsass.compileStringAsync(`
h1 {
font-size: 40px;
code {
font-face: Roboto Mono;
}
}`);
console.log(result.css);Parameters
source:string
Optional
options:StringOptions<"async">
ReturnsPromise<CompileResult>
- Defined injs-api-doc/compile.d.ts:271