unimelb / unimelb-design-system

A complete design system for the University of Melbourne
https://web.unimelb.edu.au
30 stars 12 forks source link

Speed up webpack builds and fix hot module replacement #758

Closed axelboc closed 8 years ago

axelboc commented 8 years ago

Lots of stuff going on here! Fix #754

Incremental builds

webpack-dev-middleware was configured with lazy: true (the default value for this option), and was not running webpack in watch mode as a result. This is why we weren't getting incremental builds and were stuck with 60-second compilation cycles on every change.

Proxy

Turns out that webpack-dev-server has a proxy option which makes using webpack-dev-middleware irrelevant. This gets rid of the following dependencies: express, http-proxy and webpack-dev-middleware and of the WEBPACK_SERVER_PORT environment variable.

Hot Module Replacement

Even though HMR was properly configured and I got incremental builds to work, the page was still reloading on every change. This was caused by the ExtractTextPlugin. Using this plugin only for production builds fixed the issue and resulted in a significant speed improvement on initial build (from 60 sec to about 12 sec).

Additional improvements