Add Angular to the gulp build

Add Angular to the gulp build

Finally, we need to make sure that the Angular files are copied as part of the build. We need to add:

  1. The paths to the library files.
  2. Add a lib task to pipe the files to wwwroot.
  3. Add a dependendency on lib to the default task.

The updated gulpfile.js should look like this:

/// <binding AfterBuild='default' Clean='clean' />
/*
This file is the main entry point for defining Gulp tasks and using Gulp plugins.
Click here to learn more. http://go.microsoft.com/fwlink/?LinkId=518007
*/

var gulp = require('gulp');
var del = require('del');

var paths = {
  scripts: ['scripts/**/*.js', 'scripts/**/*.ts', 'scripts/**/*.map'],
  libs: ['node_modules/angular2/bundles/angular2.js',
       'node_modules/angular2/bundles/angular2-polyfills.js',
       'node_modules/systemjs/dist/system.src.js',
       'node_modules/rxjs/bundles/Rx.js']
};

gulp.task('lib', function () {
  gulp.src(paths.libs).pipe(gulp.dest('wwwroot/scripts/lib'))
});

gulp.task('clean', function () {
  return del(['wwwroot/scripts/**/*']);
});

gulp.task('default', ['lib'], function () {
  gulp.src(paths.scripts).pipe(gulp.dest('wwwroot/scripts'))
});

Again, make sure that Task Runner Explorer sees the new lib task after you save the gulpfile.

doc_TypeScript
2016-10-04 19:24:59
Comments
Leave a Comment

Please login to continue.