I have two gulp tasks I need to run, one for js
, one for css
. I need them to run differently for build-dev
(not minified) and build-prod
(minified).
To do this, I stripped out the minification and gulp.dest portions of the tasks for js
and css
and am instead returning gulp.src to the tasks build-prod
or build-dev
. These two tasks build-prod
or build-dev
are now responsible for manipulating the js
and css
tasks differently.
How can I return the tasks' gulp.src
to build-prod
or build-dev
for continued piping?
Note: since it's a stream, it seems I'm returning the stream after the last pipe finishes for that task, then since it's asynchronous, why can't I chain pipes after gulp.src
returns?
gulp.task('css', function() {
return gulp.src('css/**.css')
.pipe(autoprefixer('last 10 version'))
.pipe(concatCss('main.css'));
// .pipe(minifycss())
// .pipe(gulp.dest('build/css'));
});
gulp.task('js', ...
return gulp.src(['./js/**/*.js'])
.pipe(
... // Huge function that I don't want to duplicate
});
gulp.task('build-prod', function() {
gulp.run('css')
.pipe(minifycss())
.pipe(gulp.dest('build/css'));
gulp.run('scripts')
.pipe(minifyjs())
.pipe(gulp.dest('build/js'));
});
gulp.task('build-dev', function() {
gulp.run('css')
.pipe(gulp.dest('build/css'));
gulp.run('scripts')
.pipe(gulp.dest('build/js'));
});