title: How to Pass Data OR communicate Between Two Dependent Gulp tasks?
body: <p>i want to run task in sequence, but want to pass data from one task to another.</p>
  
  <p>Here is my code.</p>
  
  <p>Gulp task 1 -> compile Html</p>
  
  <pre><code>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/'));
  
  });
  </code></pre>
  
  <p>Gulp Task 2 -> generate build </p>
  
  <pre><code>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);
  
  });
  </code></pre>
  
  <p>currently i am using timeout in task 2 to give time for render templates according to environment.</p>
  
  <p>task 2 (generate build) requirements</p>
  
  <ol>
  <li>change environment in templateConfig, so template are generated accordingly</li>
  <li>compile the template using task 1</li>
  <li>wait for compilation to finish, can take long time</li>
  <li>generate build to dist</li>
  </ol>