- compile(path:string,options?:Options<"sync">):CompileResult
- Dart Sass
- since 1.45.0
- Node Sass
- ✗
Compatibility:Synchronously compiles the Sass file at
path
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
Optional
options:Options<"sync">
ReturnsCompileResult
- Defined injs-api-doc/compile.d.ts:168