typescriptgulpgulp-typescript

gulp-typescript not including file


I have this directory structure for a TypeScript app.

app/   
 --/components/
    --/component1/
       --component1.ts   
 --/scripts/
      --entry.ts
.tmp/

gulpfile:

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

If I do this:

gulp.task('typescript', function () {
        return gulp.src('app/**/*.ts')
            .pipe(ts())
        .pipe(gulp.dest('.tmp/scripts'))
    });

All typescript files generate their respective JavaScript files into the .tmp directory, with the same file structure as is in the main app:

 .tmp/   
     --/components/
        --/component1/
           --component1.js   
     --/scripts/
          --entry.js

But I want to create one output file. If I do this:

gulp.task('typescript', function () {
    return gulp.src('app/**/*.ts')
        .pipe(ts({
           out: 'app.js'
        }))
        .pipe(gulp.dest('.tmp/scripts'));
});

.tmp/scripts/app.js is generated, but it only includes code from "entry.ts" - nothing from "component1.ts"

What am I doing wrong? new to gulp.


Solution

  • What am I doing wrong?

    Usage of out is not recommended : https://basarat.gitbooks.io/typescript/content/docs/tips/outFile.html