UNPKG

slush-squarespace

Version:

A slush generator for working in an external environment on the Squarespace consumer platform

105 lines (90 loc) 2.56 kB
var gulp = require('gulp'), prefix = require('gulp-autoprefixer'), concat = require('gulp-concat'), csso = require('gulp-csso'), notify = require('gulp-notify'), plumber = require('gulp-plumber'), rename = require('gulp-rename'), sass = require('gulp-sass'), uglify = require('gulp-uglify'), util = require('gulp-util'), watch = require('gulp-watch'), sftp = require('gulp-sftp'), ftpSettings = require('./ftp.json'), gulpIf = require('gulp-if'); // define noError to allow success messages var noError = true; // error handler var onError = function(err) { notify.onError({ title: "Gulp - Failure!", message: "Error:" + err.message, sound: "Beep" })(err); noError = false; this.emit('end'); }; // compile Scss with autoprefixer and csso gulp.task('styles', function () { // error handling reset noError = true; return gulp.src('src/scss/**/*.scss') .pipe(plumber({errorHandler: onError})) .pipe(sass()) .pipe(prefix({ browsers: ['last 3 versions'] })) .pipe(csso()) .pipe(rename({ basename: 'dist', suffix: '.min' })) .pipe(gulp.dest("./dist")) .pipe(gulpIf(noError, notify({ title: 'Gulp - Styles', message: 'Success', sound: "Pop" }) )); }); // compile JS and uglify gulp.task('scripts', function() { // error handling reset noError = true; return gulp.src('src/js/**/*.js') .pipe(plumber({errorHandler: onError})) .pipe(concat('all.js')) .pipe(uglify()) .pipe(rename({ basename: 'dist', suffix: '.min' })) .pipe(gulp.dest("./dist")) .pipe(gulpIf(noError, notify({ title: 'Gulp - Scripts', message: 'Success', sound: "Pop" }) )); });<% if (tools.indexOf("Auto SFTP") > -1) { %> gulp.task('deploy', function() { return gulp.src('dist/*') .pipe(sftp({ host: ftpSettings.host, user: ftpSettings.user, pass: ftpSettings.pass, remotePath: ftpSettings.path })); });<% } %> // Watch Files For Changes gulp.task('watch', function() { gulp.watch('src/scss/**/*.scss', ['styles']); gulp.watch('src/js/**/*.js', ['scripts']);<% if (tools.indexOf("Auto SFTP") > -1) { %> gulp.watch('dist/**', ['deploy']);<% } %> }); // Default Task gulp.task('default', ['watch']); // end of document //