-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from stryju/master
added recipe: "Using external config file"
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Using external config file | ||
## bonus: keeping those tasks DRY | ||
## bonus2: config.json can be used by another task runner, like `Grunt` | ||
|
||
--- | ||
|
||
`config.json` | ||
|
||
```json | ||
{ | ||
"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" | ||
} | ||
} | ||
``` | ||
|
||
--- | ||
|
||
`gulpfile.js` | ||
|
||
```js | ||
// npm install 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); | ||
}); | ||
``` | ||
|