- Run
npm install
. - Open
src/index.js
. Observe that onlyBadge
is imported. - Run
npx webpack
. - Run
grep -o -i -E 'avatar bundle|badge bundle' dist/main.js
. This will search the built output for the"avatar bundle"
and"badge bundle"
strings. These strings are found in theavatar.js
andbadge.js
files and are used to quickly tell if Webpack is bundling the components when building. Observe that both strings appear, meaning bothBadge
andAvatar
are bundled with the app. - In
components/avatar.js
removeAvatar = Avatar
. - In
components/badge.js
removeBadge = Badge
. - Run
npx webpack
. - Run
grep -o -i -E 'avatar bundle|badge bundle' dist/main.js
. Observe that only the"badge bundle"
string appears, meaning onlyBadge
is bundled.