Webpack (v1)


We’ve already introduced webpack in a previous lesson. It is the go-to tool across the web for bundling and compiling javascript code. There are other options out there, but at this time none of them are as popular or widely used as webpack.

In our last lesson we covered the first half of what webpack can do for you – bundling your modules. Another amazing feature is webpack’s ability to process and manipulate your code during the compilation step. So, for example, if you would like to use Sass to write your CSS, webpack can compile that for you. Webpack can manage your images and compress and optimize them for use on the web. Webpack can minify and uglify your code. There are tons of things webpack can do, but to access these functions we need to learn more about loaders and plugins.

  1. Go through the "Core Concepts" lessons at Webpack Academy. It starts off with the concepts we’ve already learned, but do the whole thing. The review is valuable and this presenter explains things very clearly. Make sure you take note of the --watch feature!

  2. Go through this tutorial to see examples of using webpack to manage your website’s assets.

  3. Finally, do this tutorial to learn how to let webpack manually manage your index.html and insert your bundle into the page for you!

  4. You don’t need to do the rest of the webpack tutorials at this time, but take a look at what’s offered on the sidebar of their guides page. There are several sweet features that you might want to use in future projects such as code-splitting, lazy-loading, and tree-shaking. Now that you have a handle on webpack’s configuration system adding these features is as easy as using the right plugins and loaders!.

Additional Resources

UPDATED: 10.03.2021

  • [10.03.2021] Adding resource for parcel, rollup and esbuild bundlers.