Yesterday I needed a way to load self-contained code units into my AngularJS app. I’ve had this problem before and tried using and Grunt.js to solve it. It was messy. Then I discovered Webpack!

Webpack is a module bundler. It takes JavaScript, CSS, HTML and pretty much anything else you can think of and bundles it into a single file. Okay, but Grunt or Gulp can do that too. Yes, but Webpack also allows requiring files like one does in Node.js. It allows relative paths, something which AngularJS’s templateUrls does not!

Combined with ocLazyLoad and Webpack’s chunking feature, I finally have a decent solution to creating completely modular Angular components.