Why Angular CLI Doesn't Expose Webpack

by Stephen Fluin

2017-06-21

Why Angular CLI Doesn't Expose Webpack
The Angular CLI is an awesome tool that automates many parts of the developer workflow.
  1. Scaffolding
  2. Serving Dev Mode
  3. Production Builds
  4. Test Running

It's amazing in the way that it gets you up and running pushing pixels to the screen using Angular as fast as possible.
It's problematic in some use cases (Angular Universal being a very common one) in that it doesn't expose any of the underlying webpack config. Developers ask for this often, and the long term goal is to support add-ons, but a lack of support today is intentional.

Why not let developers modify the webpack config?

TL;DR: The team is future proofing your applications for you

Module Loading and Bundling

The state of module loading / bundling is going to change dramatically over the next 12-24 months.
Today, the latest and freshest versions of Chrome are shipping with ES2015 Module Support, but for the last couple of years, we already had SystemJS, Webpack, Closure, and other tools handling JavaScript application bundling, implementing the same spec.

Discord between browsers and tools

Both browsers and build tools today are implementing the same specifications, but each has very different functionality. Webpack supports local path resolution, browsers don't. Webpack resolves these without runtime processing. The browser can load modules only as needed.
There are fundamental design differences with both pros and cons. Based on the rate of change in the browsers and bundlers, we can expect each and every bundler to continue to change and improve its functionality. These improvements will likely include changes to the way they load modules, and change the way they produce code for the browser to match both match and to take advantage of the browsers' new capabilities.

The CLI is protecting you

If the CLI let you modify your Webpack configuration, it's very probable that you would do something that wouldn't be compatible with these future changes to the bundlers. By hiding the Webpack config, the Angular CLI can modify the way it uses Webpack to ensure that your code continues to work despite the shifting landscape.

A crazy future

There are also theoretical futures where Webpack is no longer the best option for Angular developers, and at some point in the future the CLI team might decide they want to switch to an alternative tool (Rollup, Closure, something brand new?). By not building your application for Webpack, Angular CLI-based applications can continue to grow and improve without worry about the underlying tools.