Skip to content

Instantly share code, notes, and snippets.

@BDQ
Created September 20, 2014 16:01
Show Gist options
  • Save BDQ/1326ce6f0e8fb67bfd3e to your computer and use it in GitHub Desktop.
Save BDQ/1326ce6f0e8fb67bfd3e to your computer and use it in GitHub Desktop.
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var tmplte = require('gulp-jstemplater');
// Lint Task
gulp.task('lint', function() {
return gulp.src('src/js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Concatenate JS templates
gulp.task('templates', function() {
return gulp.src(['src/js/views/**/*.html'])
.pipe(tmplte("templates.js", {variable: "TMPL"}))
.pipe(gulp.dest('src/js/'));
});
// Concatenate & Minify JS
gulp.task('scripts', function() {
return gulp.src(['src/js/vendor/*.js',
'src/js/*.js'])
.pipe(concat('all.js'))
.pipe(gulp.dest('public'))
.pipe(rename('all.min.js'))
.pipe(uglify())
.pipe(gulp.dest('public'));
});
// Concatenate css
gulp.task('styles', function() {
return gulp.src('src/css/**/*.css')
.pipe(concat('all.css'))
.pipe(gulp.dest('public'));
});
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch('src/js/**/*.js', ['scripts']);
gulp.watch('src/js/views/**/*.html', ['templates']);
gulp.watch('src/css/*.css', ['styles']);
});
// Default Task
gulp.task('default', ['styles', 'templates', 'scripts', 'watch']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment