Remove file from gulp-sourcemaps

593 Views Asked by At

I am using gulp-sourcemaps to generate inline sourcemaps for my typescripts files, however I noticed that in the sourcemap I have the source for the individual .ts files as well as the concatenated .js file. This more than doubles the size of the file. I'm only going to be using the sourcemap'd file during development, however I'd like to remove the .js source anyway.

Here are the relevant bits of my gulp file:

var es = require('event-stream');
var plug = require('gulp-load-plugins')();

var tsProject = plug.typescript.createProject({
    sortOutput: true,
    declarationFiles: true,
    target: 'es5',
    sourceRoot: './',
    noExternalResolve: true,
    module: 'none'
}); 

var sourceMapsInOptions = {
    loadMaps: true,
    debug: true
};
var sourceMapsOutOptions = {
    includeContent: true,
    sourceRoot: 'ts/',
    debug: true
};

gulp.task('compile:ts', function () {

    var tsResult = gulp.src(['typings/**/*.d.ts', '_references.d.ts', 'spa/**/*.ts'], {base:'spa'})
                    .pipe(plug.sourcemaps.init(sourceMapsInOptions))                    
                    .pipe(plug.typescript(tsProject));

    var js = tsResult.js
        .pipe(plug.concat(config.name + '.js'))
        .pipe(plug.ngAnnotate())

        .pipe(plug.uglify({ output: { beautify: false } }))
        .pipe(plug.sourcemaps.write(sourceMapsOutOptions))

        .pipe(gulp.dest(paths.output));

    var dts = tsResult.dts
        .pipe(plug.concat(config.name + '.d.ts'))
        .pipe(gulp.dest(paths.output));

    return es.merge(js, dts);

});

Does anyone have ideas on how this can be done?

0

There are 0 best solutions below