More complex than it seems
Filenames must be updated in:
• Server-side templates
• Client-side templates
• CSS (background-image, font-face, ...)
Slide 32
Slide 32 text
Requirements
Broad Module Format Compatibility
Fast Build Times
Create Common Bundle(s)
Load Files On Demand
Version Assets On A Per-file Basis
Slide 33
Slide 33 text
On The Lookout For A Bundler
Slide 34
Slide 34 text
The main contenders
Slide 35
Slide 35 text
RequireJS
Module Format Compatibility AMD, CommonJS*
Fast Build Times No ( too slow on Dev)
Create common bundles Yes ( w/ manual config)
Load files on demand Yes
Version assets per file No
Slide 36
Slide 36 text
Browserify
Module Format Compatibility CommonJS, AMD*, ES6*
Fast Build Times OK
Create common bundles Yes ( w/ plugin)
Load files on demand No
Version assets per file No
webpack -‐-‐watch
Incremental builds
DEMO: Sample Application on Github
Slide 46
Slide 46 text
Webpack Dev Server
Hot Module Replacement
DEMO: https://github.com/theasta/paris-webpack-
react#demo-5---webpack-dev-server-and-hot-
module-replacement
Slide 47
Slide 47 text
Common Chunks
webpack.optimize.CommonsChunkPlugin
can automatically create a common bundle.
Webpack analysis tool can provide hints.
DEMO: https://github.com/theasta/paris-webpack-
react#demo-2---common-chunks
Assets Versioning
Version all required files automatically and
update all filenames accordingly
DEMO: https://github.com/theasta/paris-webpack-
react#demo-4---assets-versioning
Slide 53
Slide 53 text
Webpack
✓ Broad Module Format Compatibility
✓ Fast Build Times
✓ Create Common Bundle(s)
✓ Load Files On Demand
✓ Version Assets Per File
✓ [bonus] Update Assets Filenames In Templates
and CSS
Dynamic Require
require("./models/" + type + ".js");
Includes all JS files in the models folder.
Especially useful with the FactoryPattern and
templates.
Slide 59
Slide 59 text
Embedded Stylesheets
• Possible to include CSS directly in JavaScript
• Eliminate CSS bottleneck by breaking down
styles in smaller chunks that can be loaded on
demand.
• Possible to extract the styles with the extract-
text-webpack-plugin
Slide 60
Slide 60 text
Pro Tips
Slide 61
Slide 61 text
CommonJS
Slide 62
Slide 62 text
OccurrenceOrderPlugin
Highly recommended!
Ensure the hash digest remains exactly the same
between two builds of the same codebase.