You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for this nice recipe: exactly what I needed.
My current build is:
"use strict";varbrowserify=require('browserify');vargulp=require('gulp');vargutil=require('gulp-util');varhandleErrors=require('../util/handleErrors');varsource=require('vinyl-source-stream');varwatchify=require("watchify");varlivereload=require('gulp-livereload');vargulpif=require("gulp-if");varbuffer=require('vinyl-buffer');varuglify=require('gulp-uglify');varlibs=["ajax-interceptor",//"atom-react","autolinker","bounded-cache","fuse.js","highlight.js","html-truncate","htmlsave","imagesloaded","iscroll","jquery","keymaster","lodash","medium-editor","mime-db","mime-types","moment",//"offline-js","packery","q","rangy","react","react-date-picker","spin.js","steady","store","string",//"tether-tooltip","uuid","react-dnd"];// permits to create a special bundle for vendor libs// See https://github.com/sogko/gulp-recipes/tree/master/browserify-separating-app-and-vendor-bundlesgulp.task('browserify-libs',function(){varb=browserify({debug: true});libs.forEach(function(lib){b.require(lib);});returnb.bundle().on('error',handleErrors).pipe(source('appLibs.js'))// TODO use node_env instead of "global.buildNoWatch".pipe(gulpif(global.buildNoWatch,buffer())).pipe(gulpif(global.buildNoWatch,uglify())).pipe(gulp.dest('./build'));});// Inspired by http://truongtx.me/2014/08/06/using-watchify-with-gulp-for-fast-browserify-build/gulp.task('browserify',['cleanAppJs','browserify-libs'],functionbrowserifyShare(){varb=browserify({cache: {},packageCache: {},fullPaths: true,extensions: ['.jsx'],paths: ['./node_modules','./src/'],debug: true});b.transform('reactify');libs.forEach(function(lib){b.external(lib);});// TODO use node_env instead of "global.buildNoWatch"if(!global.buildNoWatch){b=watchify(b);b.on('update',function(){gutil.log("Watchify detected change -> Rebuilding bundle");returnbundleShare(b);});}b.on('error',handleErrors);//b.add('app.js'); // It seems to produce weird behaviors when both using "add" and "require"// expose does not seem to work well... see https://github.com/substack/node-browserify/issues/850b.require('app.js',{expose: 'app'});returnbundleShare(b);});functionbundleShare(b){returnb.bundle().on('error',handleErrors).pipe(source('app.js')).pipe(gulp.dest('./build'))// TODO use node_env instead of "global.buildNoWatch".pipe(gulpif(!global.buildNoWatch,livereload()));}
It works fine, however I'm in trouble with some libraries like tether-tooltip and offline-js which are using a window global variable and node using NPM module.exports
Do you know if it is possible to add global variable dependencies to the vendor bundle? It would be a nice addition to your recipe
The text was updated successfully, but these errors were encountered:
I agree with this. In the recipe's index.html it says that angular is getting exported by the vendor bundle. This isn't the case - if you remove app.js, the console throws the angular is not defined error.
Hi,
Thanks for this nice recipe: exactly what I needed.
My current build is:
It works fine, however I'm in trouble with some libraries like
tether-tooltip
andoffline-js
which are using a window global variable and node using NPMmodule.exports
Do you know if it is possible to add global variable dependencies to the vendor bundle? It would be a nice addition to your recipe
The text was updated successfully, but these errors were encountered: