Webpack: Loaders & Code Splitting

Loaders and code splitting are two fundamental features of Webpack. Let's learn about them in this lesson.

We'll cover the following

Loaders

By default, Webpack can only bundle JavaScript and JSON files. So, if you have dependencies on any other file types, like CSS or images, you’re going to have to write some configuration rules so that Webpack can parse and bundle them.

First, you need to install a loader for a particular file type. For example, if you’re importing a CSS file somewhere, install css-loader with the command npm install --save-dev css-loader.

Then, add the rule to your config file:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.