For reasons beyond my control, I have my source code in separate, unrelated directories. Like this:
diretorioPai
foo
serverSideJS
clientSideJS
bar
serverSideJS
clientSideJS
I've set up browserify (with watchify ) to use multiple entries and have only one output. My problem is that watchify only comes with a directory - the first in the list of entries. It does not detect changes in the second directory (nor others that I add). I already noticed that no error is triggered.
These are the relevant parts of my gulpfile
:
gulp.task('js', function () {
var dir1 = '/diretorioPai/foo/clientSideJS';
var dir2 = '/diretorioPai/bar/clientSideJS'
var opts = {
entries: [dir1, dir2]
}
opts = xtend(opts, watchify.args);
var bundler = browserify(opts);
bundler = watchify(bundler);
bundler.on('update', function (file) {
gutil.log('Arquivo ' + file + ' alterado.');
rebundle();
});
function rebundle () {
return bundler
.bundle()
.on('error', function (e) {
gutil.log('Error durante a compilação. : ' + e);
})
.on('finish', function (e) {
gutil.log('Pronto.');
})
.pipe(source('app.js'))
.pipe(gulp.dest('/diretorioDeSaida/JS'));
}
return rebundle();
});
How do I make browser , or at least browserify , track files in miscellaneous directories, and compile what I find in a single file?