Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Using Webpack At Scale

Using Webpack At Scale

Webpack can be tricky, especialy as your project grows. I go over we're taking advantage of Webpack to build 9now.com.au - universal/hybrid single-page-app, and how we managed it's pains.

Basic sample configs, for the first CODE slide are on Github at https://github.com/joshhunt/webpack-simple-configs

Josh Hunt

March 14, 2016
Tweet

More Decks by Josh Hunt

Other Decks in Technology

Transcript

  1. W E B PA C K I S A M

    A Z I N G * @ J O S H H U N T
  2. Long Cache + Cache Busting 101 1. Append ID to

    each file e.g. logo-v1.png 2. Set Expires header on files to 1 year 3. *browsers will now cache assets forever* 4. When files change, change the ID e.g. logo-v2.png 5. ‘Invalidates’ logo browser cache, browsers download new one
  3. Use a plugin to create an asset manifest file that

    the server reads to get the URL
  4. [hash] is fast because it represents the entire build. Use

    during development. [chunkhash] is a hash of individual assets, so it’s slow. Use for production.
  5. W E B PA C K O N T H

    E S E RV E R
  6. T E S T I N G W E B

    PA C K I F I E D C O D E
  7. M A N A G I N G M U

    LT I P L E C O N F I G S W I T H O U T S TA B B I N G Y O U R E Y E S O U T ( M O S T LY )
  8. With server + client, you now have four Dev +

    Prod gives you two variants