Understanding configurations

The configuration is done in Webpack through the use of a configuration file, usually webpack.config.js, except in special circumstances where there can be more than one—or another—file assigned to this task. In the case of webpack.config.js, it is a JavaScript file that should be amended to alter the configuration settings of any particular project.

On startup, Webpack and Webpack 5 do not require a configuration file, but the software does recognize src/index as the default project input. It will also output the results of the build to a location named dist/main.js. This output will be "minified" and optimized for production.

Minified, or minification, simply refers to one of Webpack's main functions: to reduce the amount of code used to a minimal amount. This is done by eliminating duplicate, erroneous, or surplus code.

Typically, however, a Webpack project will need to have its default configuration changed. The default configuration is how Webpack works without any loaders or special parameters assigned to it, such as described in Chapter 1Introduction to Webpack 5, in the How Webpack works subsection. This is done through the use of the configuration file. The developer should create a file named webpack.config.js and place this in the root folder of the project. This file will be automatically detected and read by Webpack.

Let's begin our discussion by exploring the use of multiple configuration files.

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

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