gulp-typescript icon indicating copy to clipboard operation
gulp-typescript copied to clipboard

Is there something like "tsProject.out()"?

Open bennycode opened this issue 8 years ago • 2 comments
trafficstars

I am using gulp-typescript v3.1.6 and configured a gulp task with it:

const gulp = require('gulp');
const gulpTypeScript = require('gulp-typescript');
const tsProject = gulpTypeScript.createProject("tsconfig.json");

gulp.task('dist', () => {
  return tsProject.src()
    .pipe(tsProject())
    .js.pipe(gulp.dest('dist/commonjs'));
});

I would like to avoid the declaration of gulp.dest('dist/commonjs') because the output directory is already configured in the compiler options within my tsconfig.json (property "outDir"). So is there something like tsProject.out()?

This is my current workaround:

const gulp = require('gulp');
const gulpTypeScript = require('gulp-typescript');

const tsConfig = require('./tsconfig.json');
const tsProject = gulpTypeScript.createProject("tsconfig.json");

gulp.task('dist', () => {
  return tsProject.src()
    .pipe(tsProject())
    .js.pipe(gulp.dest(tsConfig.compilerOptions.outDir));
});

bennycode avatar May 07 '17 19:05 bennycode

I have been thinking on such a function, and call it tsProject.dest(). It's sadly not implemented yet. There was not an issue for that yet, so we can track that in this issue. Feel free to send a PR for this feature as I'm busy with some other projects currently.

ivogabe avatar May 09 '17 19:05 ivogabe

@bennyn Even easier is to use tsProject.options.outDir. I think it better than fidgeting with config file

smac89 avatar May 25 '17 02:05 smac89