Last active
August 29, 2015 14:17
-
-
Save kjohnson/e7c65c6ec35b8ffd5a72 to your computer and use it in GitHub Desktop.
Gulp starter for JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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