Created
November 3, 2015 22:31
-
-
Save a-am/c7dc178bbfb11df26c60 to your computer and use it in GitHub Desktop.
Gulp starter file to concat and minify javascript files
This file contains 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
/* | |
* Gulp install plugins | |
* @package.json | |
*/ | |
var gulp = require('gulp'), | |
gulpLoadPlugins = require('gulp-load-plugins'), | |
$ = gulpLoadPlugins(); | |
/* | |
* Paths for watch & processing | |
*/ | |
var paths = { | |
watch: { | |
scripts: ['assets/js/vendor/**/*','assets/js/src/**/*'] | |
}, | |
process: { | |
scripts:[ | |
'assets/js/src/master.js' | |
] | |
} | |
}; | |
/* | |
* Contact script files to master.js | |
*/ | |
gulp.task('scripts', function(){ | |
console.log('–:::– SCRIPTS –:::–'); | |
return gulp.src(paths.process.scripts) | |
.pipe($.changed('assets/js/')) | |
.pipe($.concat('master.js')) | |
.pipe(gulp.dest('assets/js/')); | |
}); | |
/* | |
* Minify master.js => master.min.js | |
*/ | |
gulp.task('compress',['scripts'], function(){ | |
console.log('–:::– COMPRESS JS –:::–'); | |
return gulp.src('assets/js/master.js') | |
.pipe($.jsmin()) | |
.pipe($.rename({suffix: '.min'})) | |
.pipe(gulp.dest('assets/js/')); | |
}); | |
/* | |
* Watch 'default' | |
*/ | |
gulp.task('default', function() { | |
gulp.watch(paths.watch.scripts, ['scripts','compress']); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment