Skip to content

Instantly share code, notes, and snippets.

@kjohnson
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save kjohnson/e7c65c6ec35b8ffd5a72 to your computer and use it in GitHub Desktop.

Select an option

Save kjohnson/e7c65c6ec35b8ffd5a72 to your computer and use it in GitHub Desktop.
Gulp starter for JS
var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
gulp.task('js', function () {
return gulp.src('assets/js/**/*.js') //select all javascript files under js/ and any subdirectory
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('assets/js/')); //the destination folder
});
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch('js/**/*.js', ['js']);
});
// Default Task
gulp.task('default', ['js', 'watch']);
function swallowError (error) {
//If you want details of the error in the console
console.log(error.toString());
this.emit('end');
}
# with Node.js and NPM installed
# install gulp and gulp packages
npm install gulp gulp-rename gulp-uglify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment