gulp.task('browserify', ['browserify-vendor'], function() { return browserify({ entries: './src/js/client.js', debug: true, fullPaths: false }) .external(VENDOR) .transform(babelify, { presets: ['es2015', 'react'] }) .bundle() .pipe(source('client.min.js')) .pipe(buffer()) .pipe(uglify({ mangle: false })) .pipe(gulp.dest(DIR+'/js')); });
gulp.task('components', function() { var viewComponets = getViewComponents(); var libs = getVendorLibs(); viewComponets.forEach(function(c) { var b = browserify(); b.transform(reactify); b.require(c.fullPath, { expose: c.name }); libs.forEach(function(l) { b.external(l.expose); }) var exposedVariables = combinedStream.create(); exposedVariables.append('var ' + c.name + ' = React.createFactory(require("' + c.name + '"));' + os.EOL); return saveBundle(b, exposedVariables, c.name + '.js', c.destDir); }) })
gulp.task('app', function () { return browserify({ insertGlobals: true, entries: build.other.client_js }) .transform(browserifyShim) .external(build.input.files.vendor_js) // .add(build.input.files.polyfill_js) .bundle() .on('error', console.error.bind(console)) .pipe(source('app.js')) // http://stackoverflow.com/questions/24992980/how-to-uglify-output-with-browserify-in-gulp // Convert from streaming to buffered vinyl file object for uglify .pipe(gulpif(minify, buffer())) .pipe(gulpif(minify, uglify())) .pipe(gulpif(minify, rename({ suffix: '.min' }))) .pipe(gulp.dest(build.output.dirs.scripts)); });
/* |-------------------------------------------------------------------------- | 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/')); } });
.external('fibers') .bundle(function (err, buffer) { if(err) {
gulp.task('server', function() { var viewComponets = getViewComponents(); var b = browserify(); b.transform(reactify); var libs = getVendorLibs(); libs.forEach(function(l) { b.external(l.expose); }) var exposedVariables = combinedStream.create(); viewComponets.forEach(function(c) { b.require(c.fullPath, { expose: c.name }); exposedVariables.append('var ' + c.name + ' = React.createFactory(require("' + c.name + '"));' + os.EOL); }) return saveBundle(b, exposedVariables, paths.dest.serverBundle, paths.dest.bundles); })
/* |-------------------------------------------------------------------------- | Compile only project files, excluding all third-party dependencies. |-------------------------------------------------------------------------- */ gulp.task('browserify', ['browserify-vendor'], function() { return browserify({ entries: 'app/main.js', debug: true }) .external(dependencies) .transform(babelify, { presets: ['es2015', 'react'] }) .bundle() .pipe(source('bundle.js')) .pipe(buffer()) .pipe(sourcemaps.init({ loadMaps: true })) .pipe(gulpif(production, uglify({ mangle: false }))) .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({ 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/')); } });
/* |-------------------------------------------------------------------------- | Compile only project files, excluding all third-party dependencies. |-------------------------------------------------------------------------- */ gulp.task('browserify', ['browserify-vendor'], function() { return browserify('app/main.js') .external(dependencies) .transform(babelify, { presets: ['es2015', 'react'] }) .bundle() .pipe(source('bundle.js')) .pipe(gulpif(production, streamify(uglify({ mangle: false })))) .pipe(gulp.dest('public/js')); });
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')); } });
/* |-------------------------------------------------------------------------- | Compile only project files, excluding all third-party dependencies. |-------------------------------------------------------------------------- */ gulp.task('browserify', ['browserify-vendor'], function() { return browserify({ entries: 'app/main.js', debug: true }) .external(dependencies) .transform(babelify, { presets: ['es2015', 'react'] }) .bundle() .pipe(source('bundle.js')) .pipe(buffer()) .pipe(sourcemaps.init({ loadMaps: true })) .pipe(gulpif(production, uglify({ mangle: false }))) .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({ 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/')); } });