sass-embedded

repository·main·Indexed 42 days ago

https://github.com/sass/embedded-host-node

A high-performance Node.js library that communicates with Embedded Dart Sass using the Embedded Sass Protocol. It serves as a faster alternative to the pure JavaScript 'sass' package by wrapping a native Dart executable. Version 1.104.1 provides synchronous and asynchronous compilation methods (compile, compileAsync, compileString, compileStringAsync) and supports various platforms including Windows, macOS, and Linux.

Tokens
7.8K
Snippets
34
Records
52
Agent score
52%

What's inside sass-embedded

  1. Understand the difference between `sass` and `sass-embedded`

    main

    While both packages implement 'Dart Sass', they differ in their underlying architecture:

    • sass: A pure JavaScript implementation.
    • sass-embedded: A JavaScript wrapper around a native Dart executable. It uses the Embedded Sass Protocol to communicate with the compiler via stdin and stdout.

    Performance Note: In sass-embedded, the asynchronous API (compileAsync) is generally faster than the synchronous API (compile) because the compilation logic runs in a separate process.

  2. Use `sass-embedded` as a drop-in replacement for `sass`

    main

    sass-embedded is a high-performance alternative to the pure JavaScript sass package. It acts as a JavaScript wrapper around a native Dart executable, making it significantly faster for large Sass compilations. It supports the same modern JavaScript API as sass and is released with the same version numbers.

    Supported Platforms:

    • Windows
    • Mac OS
    • Linux

    Note that because it relies on a native executable, it is not available on all platforms supported by the pure JS sass package.

    ```js
    const sass = require('sass-embedded');
    
    // Synchronous compilation
    const result = sass.compile(scssFilename);
    
    // OR
    
    // Asynchronous compilation (generally faster in sass-embedded)
    const result = await sass.compileAsync(scssFilename);
    ```埋
  3. Install sass-embedded for macOS (Apple Silicon)

    main

    To use the embedded Sass host on macOS with Apple Silicon (M1/M2/M3 chips), you should install the sass-embedded package. The sass-embedded-darwin-arm64 package is a platform-specific binary dependency used by sass-embedded to provide the Sass compiler functionality on darwin-arm64 architectures.

    npm install sass-embedded
  4. Install sass-embedded on Windows x64

    main

    To use the embedded Sass host on a Windows x64 platform, install the sass-embedded package via npm. The sass-embedded-win32-x64 package is a platform-specific binary dependency used by sass-embedded to provide the Sass compilation service.

    npm install sass-embedded
  5. Install sass-embedded for Android RISC-V 64-bit

    main

    The sass-embedded-android-riscv64 package provides the specific binary required to run sass-embedded on Android devices using the RISC-V 64-bit architecture. This package is a platform-specific dependency for the main sass-embedded package.

    npm install sass-embedded-android-riscv64
  6. Install sass-embedded for linux-musl-x64

    main
    The sass-embedded-linux-musl-x64 package provides the Linux musl x64 binary required for using sass-embedded in environments running on musl-based Linux distributions (such as Alpine Linux). This package is a dependency of the main sass-embedded package when running on this specific architecture.