Reduce webpack bundle size for production

_haochuan
HackerNoon.com
1 min readOct 27, 2017

--

No indroduction here, starting.

  1. Use the right environment variable

2. Use production parameter

3. Advanced uglification

4. Optimizing dependencies import

Instead of import the full dependency:

Just import what you really need:

5. Use Bundle Analyzer to figure out what increases the size

e.g. Most of the time we should ignore the moment locale files

6. Extract vendors out of your bundle

7. Extract vendors out of your bundle

8. Code split by routes

Result per step on one of my project

See ya.

--

--