Skip to content

Instantly share code, notes, and snippets.

@kbshl
Created September 16, 2014 15:08
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 kbshl/643eaf834f8cbeade3d7 to your computer and use it in GitHub Desktop.
Save kbshl/643eaf834f8cbeade3d7 to your computer and use it in GitHub Desktop.
Gulp Receipe: Using external config file
{
"desktop" : {
"src" : [
"dev/desktop/js/**/*.js",
"!dev/desktop/js/vendor/**"
],
"dest" : "build/desktop/js"
},
"mobile" : {
"src" : [
"dev/mobile/js/**/*.js",
"!dev/mobile/js/vendor/**"
],
"dest" : "build/mobile/js"
}
}
// Beneficial because it's keeping tasks DRY and config.json can be used by another task runner, like grunt.
// npm install --save-dev gulp gulp-uglify
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var config = require('./config.json');
function doStuff(cfg) {
return gulp.src(cfg.src)
.pipe(uglify())
.pipe(gulp.dest(cfg.dest));
}
gulp.task('dry', function() {
doStuff(config.desktop);
doStuff(config.mobile);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment