Skip to content

Instantly share code, notes, and snippets.

@ahmadajmi
Created September 9, 2016 16:54
Show Gist options
  • Save ahmadajmi/c8540178238a6e36601f690e818e7448 to your computer and use it in GitHub Desktop.
Save ahmadajmi/c8540178238a6e36601f690e818e7448 to your computer and use it in GitHub Desktop.
(function() {
'use strict';
// Include Gulp & Plugins
var gulp = require('gulp'),
sass = require('gulp-sass'),
cleanCSS = require('gulp-clean-css'),
autoprefixer = require('gulp-autoprefixer'),
runSequence = require('run-sequence'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
jshint = require('gulp-jshint'),
plumber = require('gulp-plumber'),
gutil = require('gulp-util');
var onError = function( err ) {
console.log('An error occurred:', gutil.colors.magenta(err.message));
gutil.beep();
this.emit('end');
};
// SASS
gulp.task('sass', function () {
return gulp.src('./assets/sass/*.scss')
.pipe(plumber({ errorHandler: onError }))
.pipe(sass())
.pipe(autoprefixer())
.pipe(rename({suffix: '.min'}))
.pipe(cleanCSS())
.pipe(gulp.dest('./assets/css'));
});
// JavaScript
gulp.task('js', function() {
return gulp.src([
'./bower_components/jquery/dist/jquery.js',
'./bower_components/jquery.fitvids/jquery.fitvids.js',
'./bower_components/jQuery-viewport-checker/dist/jquery.viewportchecker.min.js',
'./assets/js/script.js'])
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(concat('app.js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('./assets/js'));
});
// Watch
gulp.task('watch', function() {
gulp.watch('./assets/sass/**/*.scss', ['sass']);
gulp.watch('./assets/js/**/*.js', ['js']);
});
// Build
gulp.task('build', [], function() {
runSequence('sass', 'js');
});
// Default
gulp.task('default', ['watch'], function() {
gulp.start('build');
});
})();
@lewyuburi
Copy link

Can you share your package.json? Thanks for this! So good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment