Skip to content

Instantly share code, notes, and snippets.

@rmartone
Created March 2, 2015 14:59
Show Gist options
  • Save rmartone/bba859b05e70de52e160 to your computer and use it in GitHub Desktop.
Save rmartone/bba859b05e70de52e160 to your computer and use it in GitHub Desktop.
Gulp exceprt to Browserify Typescript with sourcemaps that work with Webstorm’s built-in debugger.
/**
* Browserify Typescript with sourcemaps that Webstorm can use.
* The other secret ingredient is to map the source directory to the
* remote directory through Webstorm's "Edit Configurations" dialog.
*/
'use strict';
var gulp = require('gulp'),
browserify = require('browserify'),
tsify = require('tsify'),
sourcemaps = require('gulp-sourcemaps'),
buffer = require('vinyl-buffer'),
source = require('vinyl-source-stream');
var config = {
client: {
outDir: './public/scripts',
out: 'app.js',
options: {
browserify: {
entries: './src/client/main.ts',
extensions: ['.ts'],
debug: true
},
tsify: {
target: 'ES5',
removeComments: true
}
}
}
};
gulp.task('client', function () {
return browserify(config.client.options.browserify)
.plugin(tsify, config.client.options.tsify)
.bundle()
.on('error', function (err) {
console.log(err.message);
})
.pipe(source(config.client.out))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sourcemaps.write('./', {includeContent: false, sourceRoot: '/scripts'}))
.pipe(gulp.dest(config.client.outDir));
});
@abogartz
Copy link

abogartz commented Apr 2, 2015

This doesn't seem to be working for me. Would you mind taking a screenshot of your folder structure and run configuration in Webstorm?

@rmartone
Copy link
Author

rmartone commented Aug 2, 2018

I believe this required setting up folder mappings in Webstorm. I've since moved to Webpack and found inline sourcemaps more resilient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment