How to use the browserify function in browserify

To help you get started, we’ve selected a few browserify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github freeCodeCamp / freeCodeCamp / unpack.js View on Github external
fs.mkdirp(unpackedDir, err => {
    if (err && err.code !== 'EEXIST') {
      console.log(err);
      throw err;
    }

    let unpackedFile = path.join(__dirname, 'unpacked.js');
    let b = browserify(unpackedFile).bundle();
    b.on('error', console.error);
    let unpackedBundleFile = path.join(unpackedDir, 'unpacked-bundle.js');
    const bundleFileStream = fs.createWriteStream(unpackedBundleFile);
    bundleFileStream.on('finish', () => {
      console.log('Wrote bundled JS into ' + unpackedBundleFile);
    });
    bundleFileStream.on('pipe', () => {
      console.log('Writing bundled JS...');
    });
    bundleFileStream.on('error', console.error);
    b.pipe(bundleFileStream);
    // bundleFileStream.end();  // do not do this prematurely!
  });
}
github gchudnov / inkjet / config / browserify.js View on Github external
gulp.task('script', () => {

  const isProduction = (process.env.NODE_ENV === 'production');

  const bundleConfig = {
    name: 'inkjet',
    entries: [`./src/index.js`], // require.resolve('babel-polyfill'),
    dest: './dist',
    outputName: `inkjet${isProduction ? '.min' : ''}.js`,
    isUglify: isProduction,
  };

  let bundler = browserify({
    entries: bundleConfig.entries,
    insertGlobals: false,
    detectGlobals: true,
    standalone: bundleConfig.name,
    debug: false
  });

  let bundle = () => {
    return bundler
      .bundle()
      .on('error', handleErrors)
      .pipe(source(bundleConfig.outputName))
      .pipe(header(banner, { pkg: pkg }))
      .pipe(gulpIf(bundleConfig.isUglify, uglify()))
      .pipe(gulp.dest(bundleConfig.dest))
  };
github kreativgebiet / kickup / tasks / scripts.js View on Github external
import gulp from 'gulp';
import gutil from 'gulp-util';
import uglify from 'gulp-uglify';
import browserify from 'browserify';
import watchify from 'watchify';
import source from 'vinyl-source-stream';
import buffer from 'vinyl-buffer';
import { join } from 'path';

import browserSync from './connect';
import { libraries, server, browserify as blabla } from '../config';

const { dest } = server
const config = Object.assign({}, watchify.args, blabla);
const bundler = watchify(browserify(config));
const buildBundler = browserify(config);

function bundle() {
  return bundler.bundle()
    .on('error', err => gutil.log.call(this, err))
    .pipe(source('bundle.min.js'))
    .pipe(buffer())
    .pipe(gulp.dest(dest))
    .pipe(browserSync.stream());
}

function buildBundle() {
  return buildBundler.bundle()
    .on('error', err => gutil.log.call(this, err))
    .pipe(source('bundle.min.js'))
    .pipe(buffer())
github teleport / autocomplete / gulpfile.babel.js View on Github external
const tasks = ['js/autocomplete.js', 'js/autocomplete-ractive.js'].map(entry => {
    return rebundle(browserify(assign(browserifyArgs, { entries: [entry] })), entry);
  });
github loiane / javascript-datastructures-algorithms / gulpfile.babel.js View on Github external
var tasks = files.map(function(entry) {
      return browserify({ entries: [entry] })
        .transform(babelify)
        .bundle()
        .pipe(source(entry))
        .pipe(gulp.dest(paths.dist));
    });
    es.merge(tasks).on('end', done);
github jessy1092 / react-semantify / gulpfile.babel.js View on Github external
gulp.task('browserify', () => {
  return browserify('./src/index.js', {standalone: 'Semantify'})
    .transform('babelify', {presets: ['es2015', 'react', 'stage-0']})
    .transform(globalShim.configure({
      'react': 'React'
    }))
    .bundle()
    .pipe(source('react-semantify.js'))
    .pipe(gulp.dest(build_path))
    .pipe(buffer())
    .pipe(uglify())
    .pipe(grename('react-semantify.min.js'))
    .pipe(gulp.dest(build_path));
});
github reptar / reptar / lib / theme / processor / browserify.js View on Github external
_getFile() {
    let bundle = browserify();
    bundle.add(this.assetSource);

    if (this.plugins) {
      if (!_.isUndefined(this.plugins.babelify)) {
        bundle = bundle.transform(
          babelify.configure(this.plugins.babelify || {})
        );
      }
      if (!_.isUndefined(this.plugins.uglifyify)) {
        bundle = bundle.transform(
          uglifyify
        );
      }
    }

    return new Promise((resolve, reject) => {
github brightcove / videojs-overlay / scripts / server.js View on Github external
const srces = {
  css: 'src/plugin.scss',
  js: 'src/plugin.js',
  tests: glob.sync('test/**/*.test.js')
};

const dests = {
  css: nameify('dist/%s.css'),
  js: nameify('dist/%s.js'),
  tests: 'test/dist/bundle.js'
};

const bundlers = {

  js: browserify({
    debug: true,
    entries: [srces.js],
    standalone: nameify('%s'),
    transform: [
      'babelify',
      ['browserify-shim', {global: true}],
      'browserify-versionify'
    ]
  }),

  tests: browserify({
    debug: true,
    entries: srces.tests,
    transform: [
      'babelify',
      ['browserify-shim', {global: true}],
github jessy1092 / react-github-fork-ribbon / gulpfile.babel.js View on Github external
gulp.task('browserify', () => {
  return browserify('./src/index.js')
    .transform('babelify', {presets: ['es2015', 'react', 'stage-3']})
    .transform(globalShim.configure({
      'react': 'React'
    }))
    .bundle()
    .pipe(source('react-github-fork-ribbon.js'))
    .pipe(gulp.dest(build_path))
    .pipe(buffer())
    .pipe(uglify())
    .pipe(grename('react-github-fork-ribbon.min.js'))
    .pipe(gulp.dest(build_path));
});