Modes

Once you have understood the general concepts, the first thing you need to learn about when running a build is modes. Modes are central to how Webpack works and compiles projects, so it is best to cover this brief but important topic before we go any further.

Modes use the CLI, a process that we will cover in more detail later. If you are used to using Vanilla JavaScript, this may be new to you. However, rest assured it is not a complex topic to get your head around.

Webpack ships with two configuration files, which are as follows:

  • Development config: This uses webpack-dev-server (hot reloading), debugging enabled, and so on.
  • Production config: This will spit out an optimized, minimized (uglify JS), source-mapped bundle that is used in production environments.

Since the release of version 5, Webpack takes care of the mode features by default by simply adding a mode argument to the command. Webpack can't use package.json alone to find the mode to determine the correct build path. 

Now that we have a grasp of the fundamentals, it's time to progress to the practical setup.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.8.82