Gulp - SCSS Lint - Don't compile SCSS if linting fails -
just wondering if can me gulp setup. @ moment using gulp-sass , gulp-scss-lint watch task. want happen when scss file saved linting task run , if errors or warnings thrown scss files not compile , watch continue running.
at moment seem have working errors not warnings, still compile stylesheets.
/// <binding projectopened='serve' /> // macmillan volunteering village gulp file. // used automate minification // of stylesheets , javascript files. run using either // 'gulp', 'gulp watch' or 'gulp serve' command line terminal. // // contents // -------- // 1. includes , requirements // 2. sass automation // 3. live serve // 4. watch tasks // 5. build task 'use strict'; // // 1. includes , requirements // ---------------------------- // set plugin requirements // gulp function correctly. var gulp = require('gulp'), notify = require("gulp-notify"), sass = require('gulp-sass'), scsslint = require('gulp-scss-lint'), gls = require('gulp-live-server'), // set default folder structure // variables stylesheets = 'stylesheets/', stylesheetsdist = 'content/css/', html = 'frontend/'; // // 2. sass automation // ------------------ // includes minification of sass // stylesheets. output compressed. gulp.task('sass', ['scss-lint'], function () { gulp.src(stylesheets + 'styles.scss') .pipe(sass({ outputstyle: 'compressed' })) .on("error", notify.onerror(function (error) { return error.message; })) .pipe(gulp.dest(stylesheetsdist)) .pipe(notify({ message: "stylesheets compiled", title: "stylesheets" })) }); // scss linting. ignores reset file gulp.task('scss-lint', function () { gulp.src([stylesheets + '**/*.scss', '!' + stylesheets + '**/_reset.scss']) .pipe(scsslint({ 'endless': true })) .on("error", notify.onerror(function (error) { return error.message; })) }); // // 3. live serve // ------------- gulp.task('server', function () { var server = gls.static('/'); server.start(); // browser refresh gulp.watch([stylesheets + '**/*.scss', html + '**/*.html'], function () { server.notify.apply(server, arguments); }); }); // task start server, followed watch gulp.task('serve', ['default', 'server', 'watch']); // // 4. watch tasks // -------------- gulp.task('watch', function () { // stylesheets watch gulp.watch(stylesheets + '**/*.scss', ['scss-lint', 'sass']); }); // // 5. build task // -------------- gulp.task('default', ['sass']);
Comments
Post a Comment