gulp-derequire
v3.0.0
Published
A Gulp plugin to apply derequire to target Buffer/Stream
Downloads
4,764
Readme
gulp-derequire
Description
gulp-derequire
is a gulp plugin to apply derequire to target Buffer/Stream. It's useful when you are building standalone module using browserify with gulp.
Usage
First, install gulp-derequire
as a development dependency:
npm install --save-dev gulp-derequire
Then, add it to your gulpfile.js
:
const derequire = require('gulp-derequire');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
gulp.task('build', () => {
const bundleStream = browserify({entries: './index.js', standalone: 'yourModule'}).bundle();
return bundleStream
.pipe(source('yourModule.js'))
.pipe(derequire())
.pipe(gulp.dest('./build'));
});
API
derequire(parameters)
Note: parameters are passed verbatim to derequire so see its readme for options
customization example
to change both require and define
const derequire = require('gulp-derequire');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
gulp.task('build', () => {
const bundleStream = browserify({entries: './index.js', standalone: 'yourModule'}).bundle();
return bundleStream
.pipe(source('yourModule.js'))
.pipe(derequire([
{
from: 'require',
to: '_dereq_'
},
{
from: 'define',
to: '_defi_'
}
]))
.pipe(gulp.dest('./build'));
});
Author
Support Policy
Supports Node under maintenance. In other words, we stop supporting old Node versions when their maintenance ends. Any other environments are not supported officially (means that we do not test against them on CI service).
License
Licensed under the MIT license.