I'm currently facing an issue with my task runner in the gulpfile where it is targeting all my .ts files except for resource.service.ts.
Here are the files that are accepted and targeted by the gulp script:
- main.ts
- resource.ts
- resource-list.component.ts
- test.component.ts
- test.module.ts
The specific task responsible for targeting the resource.service.ts file is the app tasks.
Below you will find my gulp script:
//References to required plugins
var gulp = require("gulp"),
gp_clean = require('gulp-clean'),
gp_concat = require('gulp-concat'),
gp_sourcemaps = require('gulp-sourcemaps'),
gp_typescript = require('gulp-typescript'),
gp_uglify = require('gulp-uglify'),
gp_typescript_config = require('gulp-ts-config');
//Define source paths
var srcPaths = {
app: ['app/main.ts', 'app/**/*.ts'],
js: ['js/**/*.js',
'node_modules/core-js/client/shim.min.js',
'node_modules/zone.js/dist/zone.js',
'node_modules/reflect-metadata/Reflect.js',
'node_modules/systemjs/dist/system.src.js',
'node_modules/typescript/lib/typescript.js']
, js_angular: ['node_modules/@angular/**']
, js_rxjs: ['node_modules/rxjs/**']
};
//Define destination paths
var destPaths = {
app: 'wwwroot/app/',
app_local: 'app/',
js: 'wwwroot/js/',
js_angular: 'wwwroot/js/@angular/',
js_rxjs: 'wwwroot/js/rxjs/'
};
//Compile, minify, and create sourcemaps for typescript files and place them in wwwroot/app, along with the js.map files
gulp.task('app', function() {
return gulp.src(srcPaths.app)
.pipe(gp_sourcemaps.init())
.pipe(gp_typescript(require('./tsconfig.json').compilerOptions))
.pipe(gp_uglify({ mangle: false }))
.pipe(gp_sourcemaps.write('/'))
.pipe(gulp.dest(destPaths.app));
});
//Delete contents of wwwroot/app
gulp.task('app-clean', function () {
return gulp.src(destPaths.app + "*", { read: false })
.pipe(gp_clean({ force: true }));
});
//Copy js files from external libraries to wwwroot/js
gulp.task('js', function () {
gulp.src(srcPaths.js_angular)
.pipe(gulp.dest(destPaths.js_angular));
gulp.src(srcPaths.js_rxjs)
.pipe(gulp.dest(destPaths.js_rxjs));
return gulp.src(srcPaths.js)
.pipe(gulp.dest(destPaths.js));
});
//Delete contents of wwwroot/js
gulp.task('js-clean', function () {
return gulp.src(destPaths.js + "*", { read: false })
.pipe(gp_clean({force: true }));
});
//Watch files and act on change
gulp.task('watch', function () {
gulp.watch([srcPaths.app, srcPaths.js], ['app', 'js']);
});
//Global clean
gulp.task('cleanup', ['app-clean', 'js-clean']);
//Default task
gulp.task('default', ['app', 'js', 'watch']);
This code is intended for use within Visual Studio 2017 environment.