JavaScript Build Tools

Julien Melissas

Hi! I'm JulienΒ πŸ€“

Twitter: @JulienMelissas

Technical Director atΒ Craftpeak

I like...

  • Dogs
  • Motorcycling
  • Travel
  • Music
  • Cooking
  • Other Stuff

Dina

Wilbur

Most days I do...

  • Websites for craft breweries
  • WordPress Development: on the roots.io team and build custom themes/websites/web applications all day
  • JS Development: Experience with React, Ember, Angular
  • UX/UI Consultation

Build Processes

(a necessary evil)

Simple Web Projects

πŸ“„

πŸ“„

πŸ“„

HTML

CSS

JS

πŸ—Ό

IMG

Modern Web Projects

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

CSS

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

JS

Β 

πŸ“„

HTML

πŸ—Ό

IMG

πŸ—Ό

IMG

πŸ“„

Vendor

Grunt

Gulp

Webpack

How Does Webpack Work?

Dependency Graphs

What is this anyways?

Webpack Core Concepts

  1. Entry: where to start grabbing top-level code to add to the bundle(s)?
  2. Output: where will the bundled codeΒ need to go once it has been processed?
  3. Loaders: transforms dependencies (entries) into JS so that webpack can understand & bundleΒ them
  4. Plugins: transforms bundlesΒ of code/assets/outputs before they are finally output

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

CSS

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

JS

Β 

πŸ“„

HTML

πŸ—Ό

IMG

πŸ—Ό

IMG

πŸ“„

Vendor

Entry Points

Where does your code come from?

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

CSS

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

Β 

πŸ“„

JS

Β 

πŸ“„

HTML

πŸ—Ό

IMG

πŸ—Ό

IMG

πŸ“„

Vendor

Outputs

Where does your code go?

Loaders

  • Webpack only understands JavaScript
  • Loaders transform files into modules
  • Loaders are defined by testΒ and use

Plugins

  • Usually used for bundles or "chunks" of code, not single files
  • Literally can do "anything" before the final bundle
  • Accept options, usually on object syntax: { }
  • new PluginName
  • Plugin examples?

Go Crazy

(webpack can do a lot)

Hot Module Replacement (HMR)

Instead of reloading the page, Webpack can INJECT new JS (and other) changes right into the page.

Code Splitting

Allows you to split up your code based on when/what you need.

Β 

Try code splitting based on routes

Tree Shaking

Tree Shaking == Dead Code Elimination

Β 

Make sure you're only importing what you need, if you're using modern JS libraries as dependencies, Webpack is already only including the code you need πŸ‘

Thanks!

Any Questions?

JavaScript Build Tools

By Julien Melissas

JavaScript Build Tools

  • 2,881