-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bundle Optimization #53
Conversation
Add a item to `package.json`'s `scripts` block to build the app and run the bundle analyzer on it.
Use the runtime-only version of Vue.js (minus the template compiler) to reduce the size of the bundle. The template compiler was only needed because of the string template in the Vue.js root, which is easily converted to a render function.
Update the arguments used to build the application when analyzing to ensure Vue's production mode is enabled.
Add `bundle-stats.json` to the list of files deleted by the clean script.
Use the standalone release of Chart.js. This removes the unused second copy of Moment.js from our bundle.
@@ -26,7 +26,14 @@ export function run(pid, canEdit, jsonAssetUrls) { | |||
new Vue({ | |||
el: '.vizr-container', | |||
components: { Vizr }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The root component is the only one with a template string (all the others are single-file components processed by vue-loader
), which is why the template compiler was required at runtime. This equivalent render function allows removing the compiler from our bundle.
This change could also be made to phenotypr-body.
@@ -65,6 +67,7 @@ module.exports = { | |||
devtool: 'cheap-source-map', | |||
plugins: [ | |||
new DefinePlugin({ | |||
'process.env.NODE_ENV': JSON.stringify(buildEnv), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allows Vue.js build process to strip out development-mode code. See the Vue.js deployment guide.
I spent some time yesterday comparing the bundles of the master branch and the vue branch using webpack-bundle-analyzer and found a couple of interesting things:
vue-loader
to pre-compile our templates.This PR makes the following optimizations:
With these changes, the vue branch's bundle is around 100 KB smaller than master when uncompressed (10 KB smaller compressed). We may get additional improvements by upgrading to Webpack 4.