Last active
December 28, 2018 21:29
-
-
Save rcline/26816c40e0115b45de7edca65cb0a998 to your computer and use it in GitHub Desktop.
Run on the Webpack Bundle Analyzer to remove all the bundle cruft and focus on the app and page bundles.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* You must keep the sidebar open while it is turning off the bundles | |
* (Window doesn't have to be active but if you mouse hovers over the webpack stats graph it will break.) | |
*/ | |
// Manually open the sidebar | |
((win) => { | |
sideBar = document.querySelectorAll('#app > div > div.Sidebar__container.Sidebar__left > button.Sidebar__toggleButton.Button__button')[0]; | |
sideBar.click(); | |
// Wait for side bar navigation to finish | |
win.setTimeout(() => { | |
// Get all the bundle items | |
bundles = document.querySelectorAll('.CheckboxList__container .CheckboxList__item'); | |
console.log(bundles.length); | |
bundles.forEach((el, i) => { | |
const fileName = el.querySelector('.Checkbox__itemText').innerHTML; | |
const label = el.querySelector('.Checkbox__label'); | |
if (fileName.includes('-formatters-') || fileName.includes('-translations-json') || fileName.includes('theme/LocaleFont')) { | |
// Set timeout otherwise browser will freeze | |
console.log(true); | |
win.setTimeout(() => { | |
console.log(fileName); | |
label.click(); | |
}, 1 + i * 250); | |
} | |
}); | |
}, 500); | |
})(this) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment