Skip to content

alexsanford/webpack-demo-aggressive-splitting

Repository files navigation

This example demonstrates extracting shared dependencies in Webpack using AggressiveSplittingPlugin.

In the example, lodash is imported by join.js and wisdom.js, and join.js is imported by greeting.js and timestamp.js. Without using AggressiveSplittingPlugin, lodash is duplicated between all of the chunks. When using the plugin, however, lodash is placed in its own chunk. That chunk is loaded the first time it is needed, and then shared after that point.

You can see this by running the example (npm start), visiting http://localhost:3000/, and clicking on each button on the page while watching the JavaScript files being loaded at each stage.

To see the behavior without AggressiveSplitPlugin, remove the plugin from webpack.config.js, restart the app, and reload the page. Now each JS file that gets loaded is much larger, since each one contains all of lodash.

About

Demo for AggressiveSplittingPlugin and dependency sharing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published