How to use the watchify.args function in watchify

To help you get started, we’ve selected a few watchify 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 callmecavs / jax.js / gulpfile.babel.js View on Github external
' */',
  ''
].join('\n')

// JS

const browserifyArgs = {
  debug: true,
  entries: 'src/jax.js',
  standalone: 'Jax',
  transform: [
    'babelify'
  ]
}

const watchifyArgs = assign(watchify.args, browserifyArgs)
const bundler = watchify(browserify(watchifyArgs))

const build = () => {
  console.log('Bundling started...')
  console.time('Bundling finished')

  return bundler
    .bundle()
    .on('error', onError)
    .on('end', () => console.timeEnd('Bundling finished'))
    .pipe(source('jax.min.js'))
    .pipe(buffer())
    .pipe(sourcemaps.init({ loadMaps: true }))
    .pipe(uglify())
    .pipe(header(attribution, { pkg: packageJSON }))
    .pipe(sourcemaps.write('./maps', { addComment: false }))
github artsy / browserify-dev-middleware / index.js View on Github external
fs.exists(path, (exists) => {
        if (!exists) return next()

        let w

        // Create a new bundle & watcher if we haven't done so. Then start
        // and initial bundling.
        if (!watchers[path]) {
          const b = browserify(_.extend(_.omit(options,
            'transforms', 'globalTransforms', 'src'
          ), watchify.args))

          b.add(path)

          const transforms = options.transforms || []
          transforms.forEach((t) => {
            b.transform(t)
          })

          const globalTransforms = options.globalTransforms || []
          globalTransforms.forEach((t) => {
            b.transform({ global: true }, t)
          })

          if (options.intercept) options.intercept(b)
          w = watchers[path] = watchify(b)
          bundleAndCache(w, path)
github risq / investigator / gulpfile.js View on Github external
function getBundler() {
  // Our browserify bundle is made up of our unit tests, which
  // should individually load up pieces of our application.
  // We also include the browserify setup file.
  var testFiles = glob.sync('./test/unit/**/*');
  var allFiles = ['./test/setup/browserify.js'].concat(testFiles);

  // Create our bundler, passing in the arguments required for watchify
  var bundler = browserify(allFiles, watchify.args);

  // Watch the bundler, and re-bundle it whenever files change
  bundler = watchify(bundler);
  bundler.on('update', function() {
    bundle(bundler);
  });

  // Set up Babelify so that ES6 works in the tests
  bundler.transform(babelify.configure({
    sourceMapRelative: __dirname + '/src'
  }));

  return bundler;
};
github cdglabs / prolog-viz / gulp / tasks / browserify2.js View on Github external
var source = require('vinyl-source-stream');
// var buffer = require('vinyl-buffer');
var gutil = require('gulp-util');
// var sourcemaps = require('gulp-sourcemaps');
var assign = require('object-assign');
var config       = require('../config').browserify;
var uglify = require('gulp-uglify');
var gulpif = require('gulp-if');
var streamify = require('gulp-streamify');

// add custom browserify options here
var customOpts = {
  entries: config.bundleConfigs[0].entries,
  debug: config.debug
};
var opts = assign({}, watchify.args, customOpts);
var b = watchify(browserify(opts));

gulp.task('browserify2', bundle); // so you can run `gulp js` to build the file
b.on('update', bundle); // on any dep update, runs the bundler
b.on('log', gutil.log); // output build logs to terminal

function bundle() {
  var condition = function (file) {
    return !config.debug;
  };

  return b.bundle()
    // log errors if they happen
    .on('error', gutil.log.bind(gutil, 'Browserify Error'))
    .pipe(source(config.bundleConfigs[0].outputName))
    .pipe(gulpif(condition,
github yiwenl / Alfrid / examples / ShadowBasic / gulpfile.babel.js View on Github external
const gulp        = require('gulp');
const babel       = require('gulp-babel');
const sourcemaps  = require('gulp-sourcemaps');
const browserSync = require('browser-sync').create();
const browserify  = require('browserify');
const babelify    = require('babelify');
const source      = require('vinyl-source-stream2')
const uglify      = require('gulp-uglify');
const sass        = require('gulp-ruby-sass');
const prefix      = require('gulp-autoprefixer');
const watchify    = require('watchify');
const buffer      = require('vinyl-buffer');
const reload      = browserSync.reload;

var bundler = watchify(browserify('./src/js/app.js', watchify.args));
bundler.transform(babelify);
gulp.task('browserify', bundle);

bundler.on('update', bundle);     

function logError(msg) {
	console.log( msg.toString() );
}

function bundle() {
    var b = bundler.bundle()
	.on('error', logError)
	.pipe(source('bundle.js'))
	.pipe(buffer())
	.pipe(sourcemaps.init({ loadMaps: true }))
	.pipe(sourcemaps.write('./'))
github Fauntleroy / react-simple-dropdown / gulpfile.js View on Github external
var generateBrowserifyBundler = function () {
    var bundler = browserify( './src/index.jsx', watchify.args );
    bundler.transform('babelify');
    bundler.transform('brfs');
    return bundler;
};
github auth0 / single-page-app-seed / gulpfile.js View on Github external
return function() {
    var file = path.resolve('index.js');
    var browserified = browserify(watchify.args);

    if (env === 'prod') {
      browserified.transform({global: true}, 'uglifyify');
    }
    if (env === 'dev') {
       browserified = watchify(browserified);
       browserified.on('update', function(){
        bundle(browserified, env);
      });
    }

    browserified.transform(stringify(['.html']));
    bundle(browserified.add(file), env);
  }
}
github loverajoel / magicplaylist / gulpfile.js View on Github external
function getBundler() {
  if (!bundler) {
    if (isProduction) {
      bundler = watchify(
        browserify([
          require.resolve('whatwg-fetch/fetch'),
          require.resolve('core-js/fn/symbol'),
          require.resolve('core-js/fn/promise'),
          config.entryFile], _.extend({ debug: true }, watchify.args)));
    } else {
      bundler = watchify(
        browserify(config.entryFile, _.extend({ debug: !isProduction }, watchify.args))
        );
    }
  }
  return bundler;
};
github bcvsolutions / CzechIdMng / Realization / frontend / czechidm-app / gulpfile.babel.js View on Github external
gulp.task('watchify', () => {
  const bundler = watchify(
    browserify(paths.srcJsx, watchify.args)
      .plugin(pathmodify, pathmodifyOptions)
      .transform(stringify)
  );

  function rebundle() {
    return bundler
      .bundle()
      .on('error', notify.onError())
      .pipe(source(paths.bundle))
      .pipe(buffer())
      .pipe(gulp.dest(paths.distJs))
      .pipe(reload({stream: true}));
  }
  //
  bundler
    .transform(babelify)
github ahutchings / react-menu-bar / gulpfile.js View on Github external
gulp.task('scripts', function () {
  var options = extend({}, watchify.args, {debug: true});
  var bundler = watchify(browserify('./example/index.jsx', options));

  bundler.transform('reactify');

  bundler.on('update', rebundle);

  function rebundle () {
    return bundler.bundle()
      .on('error', gutil.log.bind(gutil, 'Browserify Error'))
      .pipe(source('index.js'))
      .pipe(gulp.dest('./example'))
      .pipe(sync.reload({stream: true, once: true}));
  }

  return rebundle();
});

watchify

watch mode for browserify builds

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis