new SASS(optionsopt, configFileopt)
SASS compilation tools.
Wraps SASSCompiler to add linting. If you don't want that, use SASSCompiler directly.
Configures the default include paths for the following popular CSS modules:
- Bootstrap (e.g. you can write
@import "bootstrap";in your ".scss" files) - Font Awesome (
@import "font-awesome";) - 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 {SASS} from 'webcompiler';
// or - import {SASS} from 'webcompiler/lib/SASS';
// or - var SASS = require('webcompiler').SASS;
// or - var SASS = require('webcompiler/lib/SASS').SASS;
import {join} from 'path';
const scssDir = join(__dirname, 'scss'),
cssDir = join(__dirname, 'css');
const sass = new SASS();
// compile for the browser
sass.fe(join(scssDir, 'style.scss'), join(cssDir, 'style.css'));
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
options |
SASSCompilerConfig |
<optional> |
{}
|
configuration object |
configFile |
string |
<optional> |
"webcompiler/.stylelintrc.yaml"
|
path to the stylelint configuration file |
Methods
fe(inPath, outPath, lintPathsopt, callbackopt)
Wraps SASSCompiler#fe to add linting
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
inPath |
string | the input file path |
||
outPath |
string | the output file path |
||
lintPaths |
Array.<string> |
<optional> |
[]
|
an array of file globs. Ultimately passed to node-glob to figure out what files you want to lint. |
callback |
function |
<optional> |
function () {}
|
a callback function |
lint(paths, callback)
Performs linting
Parameters:
| Name | Type | Description |
|---|---|---|
paths |
Array.<string> | an array of file globs. Ultimately passed to node-glob to figure out what files you want to lint. |
callback |
function | a callback function, invoked only when successfully linted |