boday_tf/boday_it/tools/tasks/sass.js
2020-01-27 12:38:52 -05:00

39 lines
1.5 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var gutil = require('gulp-util');
var gulpif = require('gulp-if');
module.exports = function (gulp, opts) {
'use strict';
return function () {
gulp.task('sass', function () {
gulp.src(opts.PROJECT_PATTERNS.sass)
// sourcemaps can be activated through `gulp sass --debug´
.pipe(gulpif(opts.DEBUG, sourcemaps.init()))
.pipe(sass())
.on('error', function (error) {
gutil.log(gutil.colors.red(
'Error (' + error.plugin + '): ' + error.messageFormatted)
);
// used on Aldryn to inform aldryn client about the errors in
// SASS compilation
if (process.env.EXIT_ON_ERRORS) {
process.exit(1);
}
})
.pipe(autoprefixer({
// browsers are coming from browserslist file
cascade: false
}))
.pipe(minifyCss({
rebase: false
}))
// sourcemaps can be activated through `gulp sass --debug´
.pipe(gulpif(opts.DEBUG, sourcemaps.write()))
.pipe(gulp.dest(opts.PROJECT_PATH.css));
});
};
};