I am using the require and external options to reduce build times. But things break when I pass browserify files from different directories.
Here is a very simple example.
This works:
gulp.task("vendor", function () {
return gulp.src("./noop.js", {read:false}) // An empty file to start the stream
.pipe(browserify({
require: ["underscore"]
}))
.pipe(rename('vendor.js'))
.pipe(gulp.dest('./build'));
});
gulp.task("app", function () {
return gulp.src("./app.js", {read:false})
.pipe(browserify({
external: ["underscore"]
}))
.pipe(gulp.dest('./build'));
});
Result: I can access "underscore" in app.js. Everything works fine.
This doesn't work:
gulp.task("vendor", function () {
return gulp.src("./noop.js", {read:false}) // An empty file to start the stream
.pipe(browserify({
require: ["underscore"]
}))
.pipe(rename('vendor.js'))
.pipe(gulp.dest('./build'));
});
gulp.task("app", function () {
return gulp.src("./anotherDirectory/app.js", {read:false}) // THIS IS THE ONLY LINE THAT CHANGED!
.pipe(browserify({
external: ["underscore"]
}))
.pipe(gulp.dest('./build'));
});
Result: I get an error like "Cannot find module 'h15NQi' from app.js.
I am using the require and external options to reduce build times. But things break when I pass browserify files from different directories.
Here is a very simple example.
This works:
Result: I can access "underscore" in app.js. Everything works fine.
This doesn't work:
Result: I get an error like "Cannot find module 'h15NQi' from app.js.
Should changing the directory have this effect?