I'm certainly not a gulp or node specialist, so feel free to fix me / add to my answer ...
I tried to replicate a similar directory structure to what you are describing here ...
Uses gulp-tap and gulp-template
gulpfile.js
var gulp = require('gulp'); var template = require('gulp-template'); var tap = require('gulp-tap'); gulp.task('default', function () { gulp.src('./src/**/**.js', { base: './src' })
template.html
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <script src="<%- sourcefile %>"></script> </head> <body> </body> </html>
Start directory structure
. |____dist |____gulpfile.js |____src | |____bar | | |____setup.js | |____foo | | |____setup.js | |____template.html
The final directory structure
. |____dist | |____bar | | |____setup.js | | |____template.html | |____foo | | |____setup.js | | |____template.html |____gulpfile.js |____src | |____bar | | |____setup.js | |____foo | | |____setup.js | |____template.html
source share