I'm working on a nodejs project using gulp and browserify.
I want to include a folder of modules of which I don't know the filenames in my main js file.
My initial thoughts on how to approach this are:
run a gulp script to create an index.js file for all the files in the folder
require the generated index.js file in the main browserify file
run browserify
Example:
dir structrure:
/
/models
/model1.js
/model2.js
desired ouput object:
{
"model1": {...},
"model2": {...}
}
where {...} is the object exported by the file using module.exports.
Is this the right approach? Are there any better ways to approach this?
And if this is the right approach, I'm not sure how to achieve it using gulp (creating an index file), so any pointers would be greatly appreciated.
Thanks,
Rik
Aucun commentaire:
Enregistrer un commentaire