Git Product home page Git Product logo

broccoli-sass-source-maps's Introduction

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, 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'));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.