1.0.0 • Published 1 year ago

@averay/gulp-sass v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@averay/gulp-sass

View code coverage on codecov

A Gulp plugin to compile Sass files with the modern, high performance sass-embedded package.

npm install @averay/gulp-sass

Usage

Pipe the exported function into a Gulp stream:

import gulpSass from '@averay/gulp-sass';

function css() {
  gulp
    .src('css/**/*.{sass,scss}')
    .pipe(/* Apply plugins */)
    .pipe(gulpSass())
    .pipe(gulp.dest('...'));
}

The underlying Sass library can be accessed through the additional sass export (e.g. import { sass } from '@averay/gulp-sass'), or by directly importing the sass-embedded package.

Options

The function accepts an optional Sass JavaScript API StringOptions object argument.

Custom Functions

Custom Sass functions can be declared using the functions property of the options object:

import gulpSass, { sass } from '@averay/gulp-sass';

gulp.src('...').pipe(
  gulpSass({
    functions: {
      'pow($base, $exponent)': (args) => {
        const base = args[0].assertNumber('base').assertNoUnits('base');
        const exponent = args[1]
          .assertNumber('exponent')
          .assertNoUnits('exponent');

        return new sass.SassNumber(Math.pow(base.value, exponent.value));
      },
    },
  }),
);

See the Sass documentation for additional details.


MIT License