I know it's a basic question, but I couldn't find a proper answer.
Is there a way of storing a list of my project's source files in a JSON file and load it on gulpfile.js
? For example, instead of doing:
gulp.src(['a.js', 'b.js'])
Do something like:
var sources = some_load_file_func('sources.json');
gulp.src(sources.js_files))
The gulp tasks are writted in javascript file called gulpfile. js which will be executed by Gulp tool. Gulp can be installed by using npm (Node Package Manager) tool either machine wide or locally to the application.
A gulpfile is just node, and in node you can simply use require
on JSON files, like so:
var sources = require('sources.json');
Now sources will be an object (or whatever is in your JSON file).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With