My project uses two different code bases - one for desktop and one for mobile. I'd like to use the same gulp "build" task for both. My gulp "build" task for desktop looks like this:
gulp.task('build', function() {
return gulp.src([
'file1.js',
'file2.js',
'file3.js',
'file4.js',
'file5.js',
'file6.js',
'file7.js',
'file8.js',
'file9.js',
'file10.js',
])
.pipe(concat('bundle.js'))
.pipe(uglify())
.pipe(gulp.dest('desktop/dist'));
});
The only differences between these tasks is:
1) the list of files being concatenated into bundle.js
2) the prefixing dist/bundle.js with "desktop/" or "mweb/" based on which platform I'm compiling code for
Ideally, the task would be generic enough to where I could pass in a different array of files (perhaps using a function argument and/or variables), but am struggling with how to achieve this using gulp.
What I've tried so far:
My first approach was to create two separate build tasks, "desktop-build" and "mobile-build", but this approach feels bloated and redundant.