Separate angularjs library from bundled browserify -
i've got gulp task browersify files. works bundling including angular.js file quite large. want pull angular.js out , load in index.html before bundled javascript file.
i've done adding .external('angular') browserify call bundled resulting file not smaller, , when run app in browser, acts still trying load node angular package (error: uncaught error: cannot find module 'angular')
below gulp task problem believe.
function identity (input) { return input; } function bundler (watch, mocks) { var b = (watch ? watchify : identity)( browserify(watch && watchify.args) .external('angular') ); b.add(format('./%s', app)).add('babel/polyfill'); if (mocks) b.add(format('./%s/mock', app)); return b; } function bundle (bundler) { return bundler .bundle() .pipe(source('main.js')) .pipe(gulp.dest('dist/app')); } gulp.task('bundle', function () { var bundled = bundle(bundler()) if (!production) return bundled; return bundled .pipe(buffer()) .pipe(replace(/('|")use strict\1/g, '')) .pipe(plugins.uglify()) .pipe(plugins.rename({ suffix: '.min' })) .pipe(gulp.dest('dist/app')); });
Comments
Post a Comment