gulp.task('reacti', function () { var bundler = watchify(browserify(watchify.args)); console.log("==="); return bundler.add('./public/circle.jsx') .transform('reactify',{harmony:true, es6module:true}) .bundle() .pipe(source('circle.js')) .pipe(gulp.dest('public')); });
gulp.task("transform", function(){ var bundler; var bundle = function(){ return bundler.bundle() .on('error', (err) => console.log(err.message)) .pipe(source("main.js")) .pipe(gulp.dest(DEST + "/js")) .pipe(livereload()) } bundler = browserify('./app/main.js', watchify.args) bundler.transform(reactify) bundler.transform(babelify) bundler.on('update', bundle) return bundle() })
gulp.task('watchify', function () { var bundler = watchify(browserify(p.jsx, watchify.args).transform(babelify)); function rebundle() { return bundler .bundle() .on('error', notify.onError()) .pipe(source(p.bundle)) .pipe(buffer()) //.pipe(sourcemaps.init({loadMaps: true})) // Extract the inline sourcemaps //.pipe(sourcemaps.write('./map')) // Set folder for sourcemaps to output to .pipe(gulp.dest(p.distJs)) .pipe(reload({stream: true})); } bundler.transform(reactify) .on('update', rebundle); return rebundle(); });
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; }
gulp.task('browserify', ['lint'], function (done) { var args = watchify.args; args.extensions = ['.js']; watchify(browserify(path.join("./client", "index.js"), args), args) .transform(babelify) .bundle() .on('error', function(err){ console.error(err.message); done(); }) .pipe(source("app.js")) .pipe(gulp.dest("./wwwroot")) .pipe(glp.livereload()).on('end', done); });
let opts = Object.assign({}, watchify.args, browserifyOpts); let b = watch ? watchify(browserify(opts)) : browserify(opts);
_.extend(bundleConfig, watchify.args, { debug: true });
gulp.task('browserify-watch', ['browserify-vendor'], function() { var bundler = watchify(browserify({ entries: './src/js/client.js', debug: true }, watchify.args)); bundler.external(VENDOR); bundler.transform(babelify, { presets: ['es2015', 'react'] }); bundler.on('update', rebundle); return rebundle(); function rebundle() { var start = Date.now(); return bundler.bundle() .on('error', notify.onError(function(err) { return { title: 'Gulp Error: browserify-watch', message: err.toString() } })) .on('end', function() { gutil.log(gutil.colors.green('Finished: ', (Date.now() - start) + 'ms.')); }) .pipe(source('client.min.js')) .pipe(buffer()) .pipe(uglify({ mangle: false })) .pipe(gulp.dest(DIR+'/js')); } });
_.extend(bundleConfig, watchify.args, { debug: true })
/* |-------------------------------------------------------------------------- | Same as browserify task, but will also watch for changes and re-compile. |-------------------------------------------------------------------------- */ gulp.task('browserify-watch', ['browserify-vendor'], function() { var bundler = watchify(browserify({ entries: 'app/main.js', debug: true }, watchify.args)); bundler.external(dependencies); bundler.transform(babelify, { presets: ['es2015', 'react'] }); bundler.on('update', rebundle); return rebundle(); function rebundle() { var start = Date.now(); return bundler.bundle() .on('error', function(err) { gutil.log(gutil.colors.red(err.toString())); }) .on('end', function() { gutil.log(gutil.colors.green('Finished rebundling in', (Date.now() - start) + 'ms.')); }) .pipe(source('bundle.js')) .pipe(buffer()) .pipe(sourcemaps.init({ loadMaps: true })) .pipe(sourcemaps.write('.')) .pipe(gulp.dest('public/js/')); } });
/* |-------------------------------------------------------------------------- | Same as browserify task, but will also watch for changes and re-compile. |-------------------------------------------------------------------------- */ gulp.task('browserify-watch', ['browserify-vendor'], function() { var bundler = watchify(browserify('app/main.js', watchify.args)); bundler.external(dependencies); bundler.transform(babelify, { presets: ['es2015', 'react'] }) bundler.on('update', rebundle); return rebundle(); function rebundle() { var start = Date.now(); return bundler.bundle() .on('error', function(err) { gutil.log(gutil.colors.red(err.toString())); }) .on('end', function() { gutil.log(gutil.colors.green('Finished rebundling in', (Date.now() - start) + 'ms.')); }) .pipe(source('bundle.js')) .pipe(gulp.dest('public/js/')); } });
/* |-------------------------------------------------------------------------- | Same as browserify task, but will also watch for changes and re-compile. |-------------------------------------------------------------------------- */ gulp.task('browserify-watch', ['browserify-vendor'], function() { var bundler = watchify(browserify({ entries: 'app/main.js', debug: true }, watchify.args)); bundler.external(dependencies); bundler.transform(babelify, { presets: ['es2015', 'react'] }); bundler.on('update', rebundle); return rebundle(); function rebundle() { var start = Date.now(); return bundler.bundle() .on('error', function(err) { gutil.log(gutil.colors.red(err.toString())); }) .on('end', function() { gutil.log(gutil.colors.green('Finished rebundling in', (Date.now() - start) + 'ms.')); }) .pipe(source('bundle.js')) .pipe(buffer()) .pipe(sourcemaps.init({ loadMaps: true })) .pipe(sourcemaps.write('.')) .pipe(gulp.dest('public/js/')); } });