Skip to content

Instantly share code, notes, and snippets.

@a-am
Created November 3, 2015 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a-am/c7dc178bbfb11df26c60 to your computer and use it in GitHub Desktop.
Save a-am/c7dc178bbfb11df26c60 to your computer and use it in GitHub Desktop.
Gulp starter file to concat and minify javascript files
/*
* 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