0

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

  1. change environment in templateConfig, so template are generated accordingly
  2. compile the template using task 1
  3. wait for compilation to finish, can take long time
  4. generate build to dist
Maulik Anand
  • 1,429
  • 3
  • 15
  • 19

0 Answers0