Commit 97a64d3 1 parent 099a8eb commit 97a64d3 Copy full SHA for 97a64d3
File tree 2 files changed +50
-0
lines changed
2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ See [the FAQ](FAQ.md) for the answers to commonly asked questions.
13
13
* [ Working with multiple sources in one task] ( recipes/using-multiple-sources-in-one-task.md )
14
14
* [ Mocha test runner with gulp] ( recipes/mocha-test-runner-with-gulp.md )
15
15
* [ Rebuild only files that change] ( recipes/rebuild-only-files-that-change.md )
16
+ * [ Using external config file] ( recipes/using-external-config-file.md )
16
17
* [ Introduction to node.js streams] ( https://github.com/substack/stream-handbook )
17
18
18
19
## Presentations and slides
Original file line number Diff line number Diff line change
1
+ # Using external config file
2
+ ## bonus: keeping those tasks DRY
3
+ ## bonus2: config.json can be used by another task runner, like ` Grunt `
4
+
5
+ ---
6
+
7
+ ` config.json `
8
+
9
+ ``` json
10
+ {
11
+ "desktop" : {
12
+ "src" : [
13
+ " dev/desktop/js/**/*.js" ,
14
+ " !dev/desktop/js/vendor/**"
15
+ ],
16
+ "dest" : " build/desktop/js"
17
+ },
18
+ "mobile" : {
19
+ "src" : [
20
+ " dev/mobile/js/**/*.js" ,
21
+ " !dev/mobile/js/vendor/**"
22
+ ],
23
+ "dest" : " build/mobile/js"
24
+ }
25
+ }
26
+ ```
27
+
28
+ ---
29
+
30
+ ` gulpfile.js `
31
+
32
+ ``` js
33
+ // npm install gulp gulp-uglify
34
+ var gulp = require (' gulp' );
35
+ var uglify = require (' gulp-uglify' );
36
+ var config = require (' ./config.json' );
37
+
38
+ function doStuff (cfg ) {
39
+ return gulp .src (cfg .src )
40
+ .pipe (uglify ())
41
+ .pipe (gulp .dest (cfg .dest ));
42
+ }
43
+
44
+ gulp .task (' dry' , function () {
45
+ doStuff (config .desktop );
46
+ doStuff (config .mobile );
47
+ });
48
+ ```
49
+
You can’t perform that action at this time.
0 commit comments