Using Browserify

Other topics

Using Browserify with Vanilla Javascript

First install gulp and browserify via npm i gulp gulp-browserify. This will install browserify into your node_modules folder.

gulpfile.js

var gulp = require('gulp');
var browserify = require('gulp-browserify');

gulp.task('script', function() {
    gulp.src('./src/script.js')
        .pipe(browserify({
            insertGlobals: true
        })
        .pipe(gulp.dest('./build/'));
}

Using Browserify with Coffeescript

First install gulp and browserify via npm i gulp gulp-coffeeify. This will install browserify into your node_modules folder.

gulpfile.js

var gulp = require('gulp');
var coffeeify = require('gulp-coffeeify');

gulp.task('script', function() {
    gulp.src('./src/script.coffee')
        .pipe(coffeeify())
        .pipe(gulp.dest('./build/'));
}

Parameters:

OptionsDetails
transformSpecifies a pipeline of functions (or module names) through which the browserified bundle will be run.
debugEnable source map support. !gulp.env.production would work well.
extensionsArray of extensions that you want to skip in require() calls in addition to .js and .json. Don't forget .
ignoreArray of paths which should be passed to the ignore function of browserify.
resolveCustom module name resolution function.
nobuiltinsRemove builtins modules defined in lib/builtins.js (browserify module). opts.builtins must be not defined and opts.nobuiltins can be an Array of Strings or simply a String.

Contributors

Topic Id: 6364

Example Ids: 21931,21932

This site is not affiliated with any of the contributors.