There are many build tools available to JavaScript developers, but Webpack is quickly emerging as the leader of the pack. To better understand its use cases and where it excels above the rest, Jake Peyser will walk you through how to use it as a task runner and module bundler, as well as a few other handy tips. Come learn why Webpack is the most popular build tool with React developers.
2. “The module bundler. That also supports
pre-processing, code splitting, request
caching, automatic reloading…”
3. • Front end development involves many
repetitive tasks
• Production SPAs require a lot of code
per page
• Scalable web apps require efficient
static content delivery
But…
why?
6. webpack.config.js
index.js
App.js
Output
• Transpile source code using
loaders (eg. jsx -> js)
• Chain and automate the
order in which loaders run
• Common functionality is
provided by webpack and
others through plugins
Task Running
& Plugins
7. Output
webpack.config.js
• Split your code into main and vendor bundles
• Creates a single JS file for each designated bundle
• Cache code that does not change often to
decrease initial page load time
Code
Splitting
8. • Most popular build tool adopted by the React
community
• Powerful and very heavy on configuration
• create-react-app provides a boilerplate with
nice abstraction
• Most advanced features are not necessary
outside of production
Key
Points
9. • Webpack: When to Use and Why
• Gulp vs Grunt: Why use task runners and the elegance of plugins
• Create React Apps with No Configuration
• Utilizing Webpack and Babel to build a React.js App
• SurviveJS: Webpack from Apprentice to Master
• Webpack Docs
• Webpack 2.0 Docs (work in progress)
• jakepeyser/webpack-intro
Helpful
Resources
10. • DedupePlugin - Deduplicate equal or similar files in the output
• UglifyJSPlugin - Minimize all JavaScript output of chunks
• CommonsChunkPlugin - Split code into chunks
• OfflinePlugin - Makes your app offline ready by caching all (or some) output assets
• DefinePlugin - Create global constants which can be configured at compile time
• HotModuleReplacementPlugin - Enables Hot Module Replacement
• HtmlWebpackPlugin - Simplifies creation of HTML files to serve your webpack bundles
Useful
Plugins