Gulp, browser, maps?

How to enable source maps? I'm doing it:

var browserify = require("gulp-browserify") gulp.task("compile:client", function() { gulp.src("src/client/app.coffee", { read: false }) .pipe(browserify({ debug: true // THIS DOES NOTHING :( transform: ['coffeeify'], extensions: ['.coffee'] })) .pipe(rename('app.js')); }); 

Like ... for some reason, the github page for gulp -browserify says: PLUGIN BLACKLISTED.

I don't understand ... how the hell am I supposed to use a browser with my coffeescript files?

UPD: Ha! I was wrong: the debug option works. It simply inserts the source information directly into the javascript output file. Awesome. Nevertheless, the question remains open: why is this plugin blacklisted?

+6
source share
2 answers

Look at here:

https://github.com/gulpjs/plugins/issues/47

and here:

https://github.com/gulpjs/gulp/issues/369

UPDATE:

I do not think it is below "dirty."

 var source = require('vinyl-source-stream'); var browserify = require('browserify'); var bundler = browserify('./js/index.js'); gulp.task('compile', function(){ return bundler.bundle({standalone: 'noscope'}) .pipe(source('noscope.js')) .pipe(gulp.dest('./dist')); }); 
+3
source

I found a solution by scanning the website, and it looks like this:

 var browserify = require('browserify'); var gulp = require('gulp'); var exorcist = require('exorcist'); var source = require('vinyl-source-stream'); var concat = require('gulp-concat'); var uglify = require('gulp-uglify'); var sourcemaps = require('gulp-sourcemaps'); // https://www.npmjs.org/package/gulp-sourcemaps gulp.task('browserify', function(){ return browserify({ entries: ['./file1.js'], debug: true }) .bundle() .pipe(exorcist('./output.js.map')) .pipe(source('output.js')) .pipe(gulp.dest('./')); }); gulp.task('together', ['browserify'], function() { return gulp.src('output.js') .pipe(sourcemaps.init({loadMaps: true})) .pipe(concat('all-with-maps.js')) .pipe(uglify()) .pipe(sourcemaps.write('.', {addComment: true /* the default */, sourceRoot: '/src'})) .pipe(gulp.dest('dist')); }); 

Make sure the latest version of the browser is installed (I use 5.10.0 for today). You needed to pass {debug: true} to the bundle() call .. but it moved to browserify() directly.

As for the blacklist: it is believed that it is better to use browserify() directly, as we do here. There is no need for a plugin.

+10
source

All Articles