Skip to content

Commit

Permalink
Make JS source maps external.
Browse files Browse the repository at this point in the history
* add exorcist to externalize js source maps
* update write dest for gulp-sourcemaps.

This speeds up the loading of source maps in the browser by an order of
magnitude.  Don't know why.  For #9.
  • Loading branch information
cesutherland committed Dec 3, 2014
1 parent e57048f commit 20ee580
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/js-recipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ var gulpUglify = require('gulp-uglify');
var gulpUtil = require('gulp-util');
var map = require('map-stream');
var notifier = require('node-notifier');
var path = require('path');

// Optional deps:
var browserify = require('browserify');
var exorcist = require('exorcist');
var gulpBrowserify = require('gulp-browserify');
var gulpJshint = require('gulp-jshint');
var gulpNgAnnotate = require('gulp-ng-annotate');
Expand Down Expand Up @@ -128,6 +130,8 @@ function jsBase (src, out, dest, options, watch) {
// Browserify stream:
if (options.browserify) {
js = bundler.bundle()
// Exorcise the source maps:
.pipe(exorcist(path.join(dest, out + '.map')))
// Log errors if they happen
.on('error', function (e) {
var title = 'Browserify Error';
Expand All @@ -148,7 +152,7 @@ function jsBase (src, out, dest, options, watch) {
}
js = js.pipe(gulpConcat(out));
if (options.sourcemaps) {
js = js.pipe(gulpSourcemaps.write());
js = js.pipe(gulpSourcemaps.write(dest));
}
}
return js;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"mkdirp": "^0.5.0",
"less-imports": "^1.1.0",
"vinyl-buffer": "^1.0.0",
"node-notifier": "^4.0.2"
"node-notifier": "^4.0.2",
"exorcist": "^0.1.6"
}
}

0 comments on commit 20ee580

Please sign in to comment.