How can I use gulp to create Typescript source layouts in different files, and not inside javascript files?

I have a project in which I use gulp. I would like to have typescript files converted to javascript and have source maps. Here is what I have right now:

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

This works in part, but the source files are displayed inside javascript. Can someone tell me how can I do this so that it creates a sourcemap file for each javascript and not inside the map?

+7
javascript typescript gulp
source share
1 answer

You write your sourcemaps.write() as inline.

From gulp -sourcemaps repo

To write external source map files, follow the path relative to destination to sourcemaps.write ().

Must be -

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

See if this fixes the problem.

+11
source share

All Articles