🌜
🌞
sass

sass

v1.54.3

A pure JavaScript implementation of Sass.

npm install sass

README

A pure JavaScript implementation of Sass. Sass makes CSS fun again.

Sass logo npm statistics GitHub actions build status
Appveyor build status

This package is a distribution of Dart Sass, compiled to pure JavaScript with no native code or external dependencies. It provides a command-line sass executable and a Node.js API.

Usage

You can install Sass globally using npm install -g sass which will provide access to the sass executable. You can also add it to your project using npm install --save-dev sass. This provides the executable as well as a library:

const sass = require('sass');

const result = sass.compile(scssFilename);

// OR

// Note that `compileAsync()` is substantially slower than `compile()`.
const result = await sass.compileAsync(scssFilename);

See the Sass website for full API documentation.

Legacy API

Dart Sass also supports an 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.

  • Dart Sass 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.

  • Dart Sass doesn't support the sourceComments option. Source maps are the recommended way of locating the origin of generated selectors.

See Also

  • Dart Sass, from which this package is compiled, can be used either as a stand-alone executable or as a Dart library. Running Dart Sass on the Dart VM is substantially faster than running the pure JavaScript version, so this may be appropriate for performance-sensitive applications. The Dart API is also (currently) more user-friendly than the JavaScript API. See the Dart Sass README for details on how to use it.

  • Node Sass, which is a wrapper around LibSass, the C++ implementation of Sass. Node Sass supports the same API as this package and is also faster (although it's usually a little slower than Dart Sass). However, it requires a native library which may be difficult to install, and it's generally slower to add features and fix bugs.

Behavioral Differences from Ruby Sass

There are a few intentional behavioral differences between Dart Sass and Ruby Sass. These are generally places where Ruby Sass has an undesired behavior, and it's substantially easier to implement the correct behavior than it would be to implement compatible behavior. These should all have tracking bugs against Ruby Sass to update the reference behavior.

  1. @extend only accepts simple selectors, as does the second argument of selector-extend(). See issue 1599.

  2. Subject selectors are not supported. See issue 1126.

  3. Pseudo selector arguments are parsed as <declaration-value>s rather than having a more limited custom parsing. See issue 2120.

  4. The numeric precision is set to 10. See issue 1122.

  5. The indented syntax parser is more flexible: it doesn't require consistent indentation across the whole document. See issue 2176.

  6. Colors do not support channel-by-channel arithmetic. See issue 2144.

  7. Unitless numbers aren't == to unit numbers with the same value. In addition, map keys follow the same logic as ==-equality. See issue 1496.

  8. rgba() and hsla() alpha values with percentage units are interpreted as percentages. Other units are forbidden. See issue 1525.

  9. Too many variable arguments passed to a function is an error. See issue 1408.

  10. Allow @extend to reach outside a media query if there's an identical @extend defined outside that query. This isn't tracked explicitly, because it'll be irrelevant when issue 1050 is fixed.

  11. Some selector pseudos containing placeholder selectors will be compiled where they wouldn't be in Ruby Sass. This better matches the semantics of the selectors in question, and is more efficient. See issue 2228.

  12. The old-style :property value syntax is not supported in the indented syntax. See issue 2245.

  13. The reference combinator is not supported. See issue 303.

  14. Universal selector unification is symmetrical. See issue 2247.

  15. @extend doesn't produce an error if it matches but fails to unify. See issue 2250.

  16. Dart Sass currently only supports UTF-8 documents. We'd like to support more, but Dart currently doesn't support them. See dart-lang/sdk#11744, for example.

Disclaimer: this is not an official Google product.

Release Notes

1.54.3
By Sass Bot • Published on August 4, 2022

To install Sass 1.54.3, download one of the packages below and add it to your PATH, or see the Sass website for full installation instructions.

Changes

  • Release a native ARM64 executable for Mac OS.

See the full changelog for changes in earlier releases.

1.54.2
By Sass Bot • Published on August 3, 2022

To install Sass 1.54.2, download one of the packages below and add it to your PATH, or see the Sass website for full installation instructions.

Changes

  • No user-visible changes.

See the full changelog for changes in earlier releases.

1.54.1
By Sass Bot • Published on August 2, 2022

To install Sass 1.54.1, download one of the packages below and add it to your PATH, or see the Sass website for full installation instructions.

Changes

  • When unifying selectors for @extend and selector.unify(), ensure that :root, :scope, :host, and :host-context only appear at the beginning of complex selectors.

See the full changelog for changes in earlier releases.

1.54.0
By Sass Bot • Published on July 22, 2022

To install Sass 1.54.0, download one of the packages below and add it to your PATH, or see the Sass website for full installation instructions.

Changes

  • Deprecate selectors with leading or trailing combinators, or with multiple combinators in a row. If they're included in style rules after nesting is resolved, Sass will now produce a deprecation warning and, in most cases, omit the selector. Leading and trailing combinators can still be freely used for nesting purposes.

    See https://sass-lang.com/d/bogus-combinators for more details.

  • Add partial support for new media query syntax from Media Queries Level 4. The only exception are logical operations nested within parentheses, as these were previously interpreted differently as SassScript expressions.

    A parenthesized media condition that begins with not or an opening parenthesis now produces a deprecation warning. In a future release, these will be interpreted as plain CSS instead.

  • Deprecate passing non-deg units to color.hwb()'s $hue argument.

  • Fix a number of bugs when determining whether selectors with pseudo-elements are superselectors.

  • Treat * as a superselector of all selectors.

Dart API

  • Add a top-level fakeFromImport() function for testing custom importers that use AsyncImporter.fromImport.

JS API

  • Add a charset option that controls whether or not Sass emits a @charset/BOM for non-ASCII stylesheets.

  • Fix Sass npm package types for TS 4.7+ Node16 and NodeNext module resolution.

See the full changelog for changes in earlier releases.

1.53.0
By Sass Bot • Published on June 22, 2022

To install Sass 1.53.0, download one of the packages below and add it to your PATH, or see the Sass website for full installation instructions.

Changes

  • Add support for calling var() with an empty second argument, such as var(--side, ).

JS API

  • Fix a bug where meta.load-css() would sometimes resolve relative URLs incorrectly when called from a mixin using the legacy JS API.

Embedded Sass

  • Respect npm's proxy settings when downloading the embedded Sass compiler.

See the full changelog for changes in earlier releases.

1.52.3
By Sass Bot • Published on June 8, 2022

To install Sass 1.52.3, download one of the packages below and add it to your PATH, or see the Sass website for full installation instructions.

Changes

  • Fix crash when trailing loud comments (/* ... */) appear twice in a row across two different imports which themselves imported the same file each.

See the full changelog for changes in earlier releases.

1.52.2
By Sass Bot • Published on June 3, 2022

To install Sass 1.52.2, download one of the packages below and add it to your PATH, or see the Sass website for full installation instructions.

Changes

  • Preserve location of trailing loud comments (/* ... */) instead of pushing the comment to the next line.

See the full changelog for changes in earlier releases.

1.52.1
By Sass Bot • Published on May 20, 2022

To install Sass 1.52.1, download one of the packages below and add it to your PATH, or see the Sass website for full installation instructions.

Changes

Command Line Interface

  • Fix a bug where --watch mode would close immediately in TTY mode. This was caused by our change to close --watch when stdin was closed outside of TTY mode, which has been reverted for now while we work on a fix.

See the full changelog for changes in earlier releases.

1.52.0
By Sass Bot • Published on May 20, 2022

To install Sass 1.52.0, download one of the packages below and add it to your PATH, or see the Sass website for full installation instructions.

Changes

  • Add support for arbitrary modifiers at the end of plain CSS imports, in addition to the existing supports() and media queries. Sass now allows any sequence of identifiers of functions after the URL of an import for forwards compatibility with future additions to the CSS spec.

  • Fix an issue where source locations tracked through variable references could potentially become incorrect.

  • Fix a bug where a loud comment in the source can break the source map when embedding the sources, when using the command-line interface or the legacy JS API.

JS API

  • SassNumber.assertUnit() and SassNumber.assertNoUnits() now correctly return the number called on when it passes the assertion.

See the full changelog for changes in earlier releases.

General

License
MIT
Typescript Types
Built-in
Tree-shakeable
No

Popularity

GitHub Stargazers
3,271
Community Interest
3,034
Number of Forks
318

Maintenance

Commits
11/2110/22020
Last Commit
Open Issues
73
Closed Issues
799
Open Pull Requests
3
Closed Pull Requests
41

Versions

Versions Released
11/2110/2208
Latest Version Released
Aug 4, 2022
Current Tags
latest1.54.3
rc1.45.0-rc.2
test1.26.0-test.3

Dependencies

Dependencies (1)
Dev Dependencies (2)

Contributors

nex3
nex3
Commits: 1,514
jathak
jathak
Commits: 63
stof
stof
Commits: 23
Awjin
Awjin
Commits: 20
srawlins
srawlins
Commits: 10
Mstrodl
Mstrodl
Commits: 5
nshahan
nshahan
Commits: 4
MichaelRFairhurst
MichaelRFairhurst
Commits: 2
Rafer45
Rafer45
Commits: 2
chpxu
chpxu
Commits: 1
georgpukk
georgpukk
Commits: 1
BobobUnicorn
BobobUnicorn
Commits: 1
benwiley4000
benwiley4000
Commits: 1
nschonni
nschonni
Commits: 1
koorgoo
koorgoo
Commits: 1