I have a project structure that is something like that:
src
|html
|javascript
|file_one.js
|file_two.js
|styles
dist
gulpfile.js
My question is: How can I bundle all files within the "javascript" folder into the root "dist" folder renaming the bundle files in the following way?
file_one.js ----> file_one.bundle.js file_two.js ----> file_two.bundle.js
I'm doing the following, but I can't put the bundle files into the root "dist" folder, and, I don't know if this is the most pretty way.
gulp.task("bundler", function(){
var src_arr = ['src/javascript/file_one.js', 'src/javascript/file_two.js'];
src_arr.forEach(function(file) {
var bundle = browserify([file]).bundle();
bundle.pipe(source(file.substring(0,file.indexOf('.')) + ".bundle.js"))
.pipe(gulp.dest('dist/'));
});
});
Any help will be appreciated. Thanks