1. gulp-derequire
A Gulp plugin to apply derequire to target Buffer/Stream
gulp-derequire
Package: gulp-derequire
Created by: twada
Last modified: Sat, 18 Jun 2022 16:56:46 GMT
Version: 3.0.0
License: MIT
Downloads: 5,091
Repository: https://github.com/twada/gulp-derequire

Install

npm install gulp-derequire
yarn add gulp-derequire

gulp-derequire

Build Status
NPM version
Code Style
License

A gulp plugin for 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.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin