Load source files from JSON file in Gulpjs

I know this is the main question, but I could not find the right answer.

Is there a way to save the list of project source files in a JSON file and upload it to gulpfile.js ? For example, instead of executing:

 gulp.src(['a.js', 'b.js']) 

Do something like:

 var sources = some_load_file_func('sources.json'); gulp.src(sources.js_files)) 
+8
json gulp
source share
1 answer

Gulpfile is just a node, and in node you can just use require in JSON files, for example:

 var sources = require('sources.json'); 

Now the source will be an object (or something else in your JSON file).

+18
source share

All Articles