i want to run task in sequence, but want to pass data from one task to another.
Here is my code.
Gulp task 1 -> compile Html
gulp.task('compile:html', function () {
return gulp.src(['src/templates/*.html', 'src/templates/*.template'])
.pipe(plumber())
.pipe(nunjucksRender({
data: templateConfig, //in templateConfig environment is saved
path: ['src/templates/']
}))
.pipe(gulp.dest('src/'));
});
Gulp Task 2 -> generate build
gulp.task('build:production', function (callback) {
var temp = templateConfig.env;
templateConfig.env = 'production';
gulp.start('compile:html');
setTimeout(function () {
//gulp.src('./src/assets/**/*.*').pipe(gulp.dest('./generated/dist/production/assets'));
gulp.src('src/*.html')
.pipe(userRef())
.pipe(gulpif('*.js', uglify()))
.pipe(gulpif('*.css', minifyCss()))
.pipe(gulp.dest('./dist/production'));
templateConfig.env = temp;
callback();
}, 2500);
});
currently i am using timeout in task 2 to give time for render templates according to environment.
task 2 (generate build) requirements
- change environment in templateConfig, so template are generated accordingly
- compile the template using task 1
- wait for compilation to finish, can take long time
- generate build to dist