I have multiple typescript files I want to pile into one single javascript file. I have the following code so far:
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 have searched online on how this is done but couldn't seem to find anything useful. I read that the 'out' option would concatenate and produce output to a single file. Can anyone point me to the right direction? So far the code I have would only create one javascript for every typescript file I have.
I have multiple typescript files I want to pile into one single javascript file. I have the following code so far:
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 have searched online on how this is done but couldn't seem to find anything useful. I read that the 'out' option would concatenate and produce output to a single file. Can anyone point me to the right direction? So far the code I have would only create one javascript for every typescript file I have.
Share Improve this question edited Mar 29, 2018 at 7:39 MSeifert 153k41 gold badges350 silver badges367 bronze badges asked Dec 20, 2014 at 8:14 user2678324user2678324 1-
1
You could use
gulp-concat
after thetypescript
mand. – Davin Tryon Commented Dec 20, 2014 at 8:23
1 Answer
Reset to default 5Davin is right.
From the gulp-typescript docs:
"Concatenate files
The tsc mand has the ability to concatenate using the --out parameter. gulp-typescript doesn't have that, because you should use the gulp-concat plugin for that, or - if you want sourcemaps - gulp-concat-sourcemaps.
The tsc mand sorts the files using the tags. gulp-typescript does this when you enable the sortOutput option. You can use the referencedFrom filter to only include files that are referenced from certain files."