Webpack - Why is my bundle.js file minified by default?

As you are using webpack 4

One of the ways is :

Inside package.json set scripts to either development or production mode

"scripts": {
  "dev": "webpack --mode development",
  "build": "webpack --mode production"
}

And now when you run npm run dev it will give you bundle.js but not minified.

But when you run npm run build it will give you a minified bundle


You are using webpack 4 without a mode setting. Normally, you should have the following warning:

WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn 
more: https://webpack.js.org/concepts/mode/

Add mode: development in your conf to disable minification and this warning.


Webpack 4 minimizes by default.

Try adding this to your module.exports in webpack.config.js.

optimization: {
    minimize: false,
}