How to compile multiple typescript files into one javascript file using Gulp?

I have several typescript files that I want to compile into a single javascript file. So far I have the following code:

var typescript = require('gulp-typescript');
gulp.task('typescript', function () {
  gulp.src('wwwroot/app/**/*.ts')
    .pipe(typescript({
      out: 'script.js'
    }))
    .pipe(sourcemaps.init())
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('wwwroot/app'))      
});

I searched the Internet for how to do this, but could not find anything useful. I read that the "exit" option combines and outputs the output into a single file. Can someone point me in the right direction? So far, the code that I have will only create one javascript for each typescript file that I have.

+4
source share
1 answer

Davin is right.

In gulp - typescript docs:

"File Concatenation

tsc -out. gulp - typescript , gulp -concat, - , - gulp -concat-sourcemaps.

tsc . gulp - typescript sortOutput. referencedFrom, , . "

+5

Source: https://habr.com/ru/post/1568440/


All Articles