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
- Entry: where to start grabbing top-level code to add to the bundle(s)?
- Output: where will the bundled codeΒ need to go once it has been processed?
- Loaders: transforms dependencies (entries) into JS so that webpack can understand & bundleΒ them
- 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
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