Skip to content

Commit

Permalink
use 'browser-pack-flat' to reduce minified bundle size!
Browse files Browse the repository at this point in the history
  • Loading branch information
etpinard committed Mar 6, 2018
1 parent b861883 commit 7b05183
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 3 deletions.
129 changes: 129 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
},
"devDependencies": {
"brfs": "^1.4.4",
"browser-pack-flat": "^3.0.8",
"browserify": "^15.2.0",
"browserify-transform-tools": "^1.7.0",
"check-node-version": "^3.2.0",
Expand Down
3 changes: 3 additions & 0 deletions tasks/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ tasks.push(function(cb) {
standalone: 'Plotly',
debug: DEV,
compressAttrs: true,
packFlat: true,
pathToMinBundle: constants.pathToPlotlyDistMin
}, cb);
});
Expand All @@ -67,6 +68,7 @@ tasks.push(function(cb) {
_bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyDistWithMeta, {
standalone: 'Plotly',
debug: DEV,
packFlat: true
}, function() {
makeSchema(constants.pathToPlotlyDistWithMeta, constants.pathToSchema)();
cb();
Expand All @@ -80,6 +82,7 @@ constants.partialBundlePaths.forEach(function(pathObj) {
standalone: 'Plotly',
debug: DEV,
compressAttrs: true,
packFlat: true,
pathToMinBundle: pathObj.distMin
}, cb);
});
Expand Down
8 changes: 5 additions & 3 deletions tasks/util/browserify_wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var fs = require('fs');
var path = require('path');

var browserify = require('browserify');
var packFlat = require('browser-pack-flat/plugin');
var minify = require('minify-stream');

var constants = require('./constants');
Expand All @@ -12,16 +13,14 @@ var strictD3 = require('./strict_d3');
*
* @param {string} pathToIndex path to index file to bundle
* @param {string} pathToBunlde path to destination bundle
*
* @param {object} opts
*
* Browserify options:
* - standalone {string}
* - debug {boolean} [optional]
*
* Additional option:
* - pathToMinBundle {string} path to destination minified bundle
* - compressAttrs {boolean} do we compress attribute meta?
* - packFlat {boolean} do we use browser-pack-flat plugin?
* @param {function} cb callback
*
* Outputs one bundle (un-minified) file if opts.pathToMinBundle is omitted
Expand Down Expand Up @@ -49,6 +48,9 @@ module.exports = function _bundle(pathToIndex, pathToBundle, opts, cb) {

var b = browserify(pathToIndex, browserifyOpts);

if(opts.packFlat) {
b.plugin(packFlat);
}

var pending = opts.pathToMinBundle ? 2 : 1;

Expand Down

0 comments on commit 7b05183

Please sign in to comment.