Skip to content

Instantly share code, notes, and snippets.

@spajak
Last active June 11, 2019 16:48
Show Gist options
  • Save spajak/cdab229f46df4690b1e832d18be6a371 to your computer and use it in GitHub Desktop.
Save spajak/cdab229f46df4690b1e832d18be6a371 to your computer and use it in GitHub Desktop.
Sample config for gulp
var gulp = require('gulp');
// Include Our Plugins
var jshint = require('gulp-jshint');
var sasslint = require('gulp-sass-lint');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
// JS Lint Task
gulp.task('jslint', function() {
return gulp.src('src/js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
});
// Sass Lint Task
gulp.task('sasslint', function() {
return gulp.src('src/scss/*.scss')
.pipe(sasslint())
.pipe(sasslint.format())
.pipe(sasslint.failOnError());
});
// Compile Our Sass
gulp.task('sass', ['sasslint'], function() {
return gulp.src('src/scss/*.scss')
.pipe(sass())
.pipe(gulp.dest('dist/css'));
});
// Concatenate & Minify JS
gulp.task('js', ['jslint'], function() {
return gulp.src('src/js/*.js')
.pipe(concat('all.js'))
.pipe(gulp.dest('dist/js'))
.pipe(rename('all.min.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/js'));
});
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch('src/js/*.js', ['js']);
gulp.watch('src/scss/*.scss', ['sass']);
});
gulp.task('default', ['js', 'sass', 'watch']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment