• Stars
    star
    149
  • Rank 248,619 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 5 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Node.js library that will communicate with Embedded Dart Sass using the Embedded Sass protocol

Embedded Sass Host

This package is an alternative to the sass package. It supports the same JS API as sass and is maintained by the same team, but where the sass package is pure JavaScript, sass-embedded is instead a JavaScript wrapper around a native Dart executable. This means sass-embedded will generally be much faster especially for large Sass compilations, but it can only be installed on the platforms that Dart supports: Windows, Mac OS, and Linux.

Despite being different packages, both sass and sass-embedded are considered "Dart Sass" since they have the same underlying implementation. Since the first stable release of the sass-embedded package, both packages are released at the same time and share the same version number.

Usage

This package provides the same JavaScript API as the sass package, and can be used as a drop-in replacement:

const sass = require('sass-embedded');

const result = sass.compile(scssFilename);

// OR

const result = await sass.compileAsync(scssFilename);

Unlike the sass package, the asynchronous API in sass-embedded will generally be faster than the synchronous API since the Sass compilation logic is happening in a different process.

See the Sass website for full API documentation.

Legacy API

The sass-embedded package also supports the older JavaScript API that's fully compatible with Node Sass (with a few exceptions listed below), with support for both the render() and renderSync() functions. This API is considered deprecated and will be removed in Dart Sass 2.0.0, so it should be avoided in new projects.

Sass's support for the legacy JavaScript API has the following limitations:

  • Only the "expanded" and "compressed" values of outputStyle are supported.

  • The sass-embedded package doesn't support the precision option. Dart Sass defaults to a sufficiently high precision for all existing browsers, and making this customizable would make the code substantially less efficient.

  • The sass-embedded package doesn't support the [sourceComments] option. Source maps are the recommended way of locating the origin of generated selectors.

  • The sass-embedded package doesn't support the indentWidth, indentType, or linefeed options. It implements the legacy API as a wrapper around the new API, and the new API has dropped support for these options.

How Does It Work?

The sass-embedded runs the Dart Sass embedded compiler as a separate executable and uses the Embedded Sass Protocol to communicate with it over its stdin and stdout streams. This protocol is designed to make it possible not only to start a Sass compilation, but to control aspects of it that are exposed by an API. This includes defining custom importers, functions, and loggers, all of which are invoked by messages from the embedded compiler back to the host.

Although this sort of two-way communication with an embedded process is inherently asynchronous in Node.js, this package supports the synchronous compile() API using a custom synchronous message-passing library that's implemented with the Atomics.wait() primitive. We hope to release this library as a stand-alone package at some point in the future.


Disclaimer: this is not an official Google product.

More Repositories

1

sass

Sass makes CSS fun!
TypeScript
15,081
star
2

node-sass

🌈 Node.js bindings to libsass
C++
8,506
star
3

libsass

A C/C++ implementation of a Sass compiler
C++
4,331
star
4

dart-sass

The reference implementation of Sass, written in Dart.
Dart
3,913
star
5

sassc

libsass command line driver
C
785
star
6

sassc-rails

Integrate SassC-Ruby with Rails!
HTML
707
star
7

libsass-python

A straightforward binding of libsass for Python. Compile Sass/SCSS in Python with no Ruby stack at all!
Python
560
star
8

sassc-ruby

Use libsass with Ruby!
Ruby
365
star
9

sass-site

Sass Website
TypeScript
312
star
10

node-sass-middleware

connect middleware extracted from node-sass
JavaScript
263
star
11

sass-spec

Official Sass Spec Suite
SCSS
200
star
12

ruby-sass

The original, now deprecated Ruby implementation of Sass
Ruby
181
star
13

node-sass-binaries

Platform specific binaries for node-sass
127
star
14

libsass-net

A lightweight wrapper around libsass
C#
95
star
15

migrator

Tool for migrating stylesheets to new Sass versions
Dart
84
star
16

ruby-libsass

Ruby bindings for libsass
Ruby
81
star
17

dart-sass-embedded

A wrapper for Dart Sass that implements the compiler side of the Embedded Sass protocol
Dart
66
star
18

linter

An experimental Sass linter written using the Dart Sass AST
Dart
39
star
19

homebrew-sass

A Homebrew tap for Sass
Ruby
35
star
20

embedded-protocol

A protocol for communicating between a Sass implementation and a host language
31
star
21

perl-libsass

Perl bindings for libsass (CSS::Sass)
Perl
29
star
22

sass-registry

Extension registry for Sass
Ruby
7
star
23

libsass.com

CSS
6
star
24

sass-site-built

The built HTML of the Sass website, used to see output diffs in code reviews
HTML
6
star
25

clone-linked-repo

A utility action that emits information about one PR linked from another's message
Shell
3
star