Skip to content

Latest commit

 

History

History
37 lines (23 loc) · 1.42 KB

README.md

File metadata and controls

37 lines (23 loc) · 1.42 KB

Code minification

Minify javascript

Webpack v5 comes with the latest terser-webpack-plugin out of the box (no need to install it).

Running webpack in production mode will enable minification by default.

To remove console.log() statements add drop_console to terserOptions.

Minify css

Use css-minimizer-webpack-plugin to minify and remove duplicates css.

optimization: {
  minimizer: [
    // Tells webpack@5 to extend defaults minimizer options
    `...`,
    new CssMinimizerPlugin()
  ]
}

This config will enable css optimization only in production mode.

Minify html

Use HtmlWebpackPlugin.minify to minimize html.

Note

To enable minification in development set optimization.minimize: true.

You can override the default minimizer with optimization.minimizer option.

Source maps like eval don't work with minimizer enable.