since gulp-browserify module is blacklisted I`ve tried to rewrite my old code in gulpfile.js without gulp-browserify.
I have this worked task with gulp-browserify
var gulp = require('gulp'),
browserify = require('gulp-browserify');
gulp.task('browserify', function() {
return gulp.src('./lib/tssoft.commons.js')
.pipe(browserify({
ignore: ['jsdom']
}))
.pipe(gulp.dest('./dist/'))
});
as you see I tell gulp-browserify to ignore require('jsdom') in browserifying.
After gulp-browserify was uninstalled I instal browserify module and rewrite code
var gulp = require('gulp'),
browserify = require('browserify');
gulp.task('browserify', function() {
var b = browserify();
b.ignore('jsdom');
b.add('./lib/tssoft.commons.js');
return b.bundle()
.pipe(gulp.dest('./dist/'));
});
And get this error: "Arguments to path.resolve must be strings".
Stumpled upon this just a couple days ago, here you go:
var gulp = require('gulp'),
browserify = require('browserify'),
source = require('vinyl-source-stream');
gulp.task('browserify', function() {
var b = browserify();
b.ignore('jsdom');
var path = './lib/tssoft.commons.js';
b.add(path);
return b.bundle()
.pipe(source(path))
.pipe(gulp.dest('./dist/'));
});
The gulp-browerify ignore need a absolute path。 So you just :
var gulp = require('gulp'),
browserify = require('gulp-browserify');
gulp.task('browserify', function() {
return gulp.src('./lib/tssoft.commons.js')
.pipe(browserify({
ignore: [require.resolve('jsdom')]
}))
.pipe(gulp.dest('./dist/'))
});
Good luck
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With