SASSCompiler

SASSCompiler

new SASSCompiler(optionsopt)

Source:

A SASS compiler

Configures the default include paths for the following popular CSS modules:

  1. Bootstrap (e.g. you can write @import "bootstrap"; in your ".scss" files)
  2. Font Awesome (@import "font-awesome";)
  3. Bootswatch (@import "cosmo/variables"; @import "bootstrap"; @import "cosmo/bootswatch";)

Additionally, if an NPM module contains an _index.scss (or _index.sass, or index.scss, or index.sass) file in its root directory, importing its stylesheets is as easy as: @import "<module name>"; (same as you would import the module in JavaScript).

Example
import {SASSCompiler} from 'webcompiler';
// or - import {SASSCompiler} from 'webcompiler/lib/SASSCompiler';
// or - var SASSCompiler = require('webcompiler').SASSCompiler;
// or - var SASSCompiler = require('webcompiler/lib/SASSCompiler').SASSCompiler;
import {join} from 'path';

const scssDir = join(__dirname, 'scss'),
  cssDir = join(__dirname, 'css');

const compiler = new SASSCompiler();

// compile for the browser
compiler.fe(join(scssDir, 'style.scss'), join(cssDir, 'style.css'));
Parameters:
Name Type Attributes Default Description
options SASSCompilerConfig <optional>
{}

configuration object

Extends

Methods

addPostcssPlugins(…plugins) → {SASSCompiler}

Source:

Adds postcss plugins (autoprefixer is included by default).

Parameters:
Name Type Attributes Description
plugins * <repeatable>

postcss plugins

Returns:

self

Type
SASSCompiler

fe(inPath, outPath, callbackopt)

Source:

Compiles, runs postcss on the result and, optionally, g-zips in the production mode.

Parameters:
Name Type Attributes Default Description
inPath string

a full system path to the input file

outPath string

a full system path to the output file

callback function <optional>
function () {}

a callback function

postcss(path, data, callback)

Source:

Runs the compiled code through the list of configured postcss plugins.

Parameters:
Name Type Description
path string

a path to the file

data ProgramData

the actual program data to execute postcss on

callback ProgramDataCallback

a callback function

(protected) save(inPath, outPath, data, callback)

Source:
Inherited From:

G-zips the program if necessary and writes the results to disk.

Skips the final write if the contents of the file have not changed since the previous write. Which adds a little overhead at compile time, but at the same time does not alter the last modified timestamp of the file unnecessarily.

Good news for someone who is using that timestamp for public cache invalidation.

Parameters:
Name Type Description
inPath string

the input path

outPath string

the output path

data ProgramData

processed application code with source maps

callback function

a callback function