compileString

  • Compatibility:
    Dart Sass
    since 1.45.0
    Node Sass

    Synchronously compiles a stylesheet whose contents is source to CSS. If it succeeds it returns a CompileResult, and if it fails it throws an Exception.

    This only allows synchronous Importers and CustomFunctions.

    Example

    const sass = require('sass');

    const result = sass.compileString(`
    h1 {
    font-size: 40px;
    code {
    font-face: Roboto Mono;
    }
    }`);
    console.log(result.css);

    Parameters

    Returns CompileResult