2

Required steps

  1. clean build directory.
  2. compile typescript files then put compiled files in to build directory.
  3. inject compiled files as script to index.html then put it to build directory.

Project structure

-- build
-- src
   --app
     --app.ts
     ..
-- index.html

index.html

<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
    <!-- inject:js -->
    <!-- endinject -->
</body>
</html>

Gulp tasks

"devDependencies": {
   "del": "^2.2.0",
   "gulp": "^3.9.0",
   "gulp-inject": "^3.0.0",
   "gulp-typescript": "^2.10.0",
   "run-sequence": "^1.1.5"
}

gulp.task('clean', function() {
   return del('build');
});

gulp.task('ts', funtion() {
   var tsProject = ts.createProject('tsconfig.json');
   return tsProject.src('src/**/*.ts')
        .pipe(ts(tsProject))
        .js.pipe(gulp.dest('build'));
});

gulp.task('inject', funtion() {
   return gulp.src('index.html')
        .pipe(inject(gulp.src('build/**/*.js', {read: false}), {ignorePath: 'build', relative: true}))
        .pipe(gulp.dest('build'));
});

gulp.task('build', function() {
   runSequence('clean', 'ts', 'inject');
});

Problem

When I execute gulp ts && gulp inject it works perfectly.

When I excute gulp build the inject doesn't work with no message print out.

I think there are problems with run-sequence. Could you please help me to figure out the problems and how to solve it?

Quy Tang
  • 3,929
  • 1
  • 31
  • 45

1 Answers1

1

After several hours of digging, I realized that when a task returns an in-appropriate stream, run-sequence stops running with no warning or error. Hope this will help anyone else who have the same issue.

Quy Tang
  • 3,929
  • 1
  • 31
  • 45
  • Can you please tell what do you mean by in-appropriate stream. Please elaborate your answer with some code. – srikanth_k Jan 05 '17 at 10:44
  • @SrikanthReddyKarnati the code is in the question. Try to focus the `clean task`, it doesn't return a proper stream therefore the sequence stop there. – Quy Tang Jan 06 '17 at 03:05