Détail du package

broccoli-sass-source-maps

Libsass-based Sass compiler for Broccoli

broccoli-plugin, sass, scss, css

readme

broccoli-sass

The broccoli-sass plugin compiles .scss and .sass files with Dart Sass or LibSass.

This is a fork of broccoli-sass that includes support for more options and provides (partial) support for source maps by embedding the content of the SASS source files in the source map using sourcesContent.

Be aware that the paths in the generated source map not correct, but this module does what I need until the underlying issue is resolved.

Installation

npm install --save-dev broccoli-sass-source-maps sass

Usage

var compileSass = require('broccoli-sass-source-maps')(require('sass'));

var outputTree = compileSass(inputTrees, inputFile, outputFile, options);

Note that when using Dart Sass, synchronous compilation is twice as fast as asynchronous compilation by default, due to the overhead of asynchronous callbacks. To avoid this overhead, you can use the fibers package to call asynchronous importers from the synchronous code path. To enable this, pass the Fiber class to the fiber option:

var compileSass = require('broccoli-sass-source-maps')(require('sass'));
var Fiber = require('fibers');

var outputTree = compileSass(inputTrees, inputFile, outputFile, {fiber: Fiber});
  • inputTrees: An array of trees that act as the include paths for Sass. If you have a single tree, pass [tree].

  • inputFile: Relative path of the main .scss or .sass file to compile. Broccoli-sass expects to find this file in the first input tree (inputTrees[0]).

  • outputFile: Relative path of the output CSS file.

  • options: An optional hash of options for libsass and caching writer.

    • Supported Sass options are: functions, indentedSyntax, omitSourceMapUrl, outputStyle, precision, quietDeps (Dart Sass only), silenceDeprecations (Dart Sass only) sourceComments, sourceMap, sourceMapEmbed, and sourceMapContents.
    • Options for caching writer include: annotation, cacheInclude, and cacheExclude (see details here).

Example

var appCss = compileSass(['styles', 'vendor'], 'myapp/app.scss', 'assets/app.css');

Choosing the version of Sass

You must specify which version of Dart Sass or [Node Sass][] to use by passing it as a parameter to the module. Add either sass (for Dart Sass) or node-sass to your package.json and then provide that version as a parameter to the module:

// Uses Dart Sass.
var compileSass = require('broccoli-sass-source-maps')(require('sass'));

// Uses Node Sass.
var compileSass = require('broccoli-sass-source-maps')(require('node-sass'));

changelog

v4.2.4 (2023-09-16)

:bug: Bug Fix

  • #62 Use Buffer.from instead of btoa to maintain compatibility with Node 10 to 14 (@jasonbekolay)

Committers: 1

v4.2.3 (2023-09-14)

:bug: Bug Fix

Committers: 1

v4.2.2 (2023-09-13)

:bug: Bug Fix

Committers: 1

v4.2.1 (2023-09-12)

:bug: Bug Fix

Committers: 1

v4.2.0 (2023-08-14)

:rocket: Enhancement

  • #52 Allow setting the quietDeps flag if desired (@acorncom)

:house: Internal

Committers: 1

v4.1.0 (2022-10-07)

:rocket: Enhancement

:house: Internal

Committers: 1

master

  • Breaking change: This plugin now requires users to explicitly specify which Sass implementation to use when requiring() the module. For example:

    var compileSass = require('broccoli-sass-source-maps')(require('sass'));
    
  • Remove imagePath from options documentation. Support for this was removed from node-sass/libsass

  • Add functions to options documentation. See https://github.com/sass/node-sass#functions--v300---experimental (Note that if losing image-url from sass is a problem for you, you can now implement it yourself as a custom function)

0.6.4

  • Upgrade to node-sass 3.0.0-beta.5

0.6.3

  • Upgrade to node-sass 3.0.0-beta.4

0.6.2

  • Upgrade to node-sass 3.0.0-alpha.1

0.6.1

  • Update node-sass dependency

0.6.0

  • Upgrade to node-sass 3.0.0-pre

0.5.0

  • Look for main .scss file only in the first input tree (load path)

0.4.0

  • Upgrade to node-sass 2.0.1
  • Remove defective source map support; we may bring it back later

0.3.3

  • Upgrade to node-sass ^1.1.4

0.3.2

  • Fix broken release

0.3.1

  • Upgrade to node-sass ^1.0.3

0.3.0

  • Upgrade to node-sass ^1.0.1

0.2.4

  • Fix path handling issue

0.2.3

  • Cache Sass output using broccoli-caching-writer

0.2.2

  • Add support for precision option

0.2.1

  • Guard against passing a tree instead of array

0.2.0

  • Upgrade to node-sass ^0.9.2

0.1.4

  • Upgrade to node-sass 0.8.5 and make source maps work

0.1.3

  • Use new broccoli-writer base class

0.1.2

  • Update package description

0.1.1

  • Add missing cleanup method

0.1.0

  • Initial working implementation

0.0.1

  • Initial placeholder release