The Problem
Traditional static sites face a dilemma: either include all CSS and JavaScript on every page (wasting bandwidth), or manually manage imports for each page (tedious and error-prone).
Component-based sites make this worse. With dozens of components, each with its own styles and scripts, manual management becomes impossible. You need:
- Automatic discovery of which components are used
- Dependency resolution (components requiring other components)
- Proper loading order
- Bundling and optimization
- Tree-shaking to remove unused code
The metalsmith-bundled-components plugin solves all of this automatically.