Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Webpack, css-minimizer-webpack-plugin vs mini-css-extract-plugin

I am always using mini-css-extract-plugin to optimize CSS. Today I found a new project, css-minimizer-webpack-plugin from here, seems like this project do the same thing as mini-css-extract-plugin.

What is the advantage of css-minimizer-webpack-plugin? I read the docs and article from google, seems no one is talking about it? Should I use css-minimizer-webpack-plugin to replace the mini-css-extract-plugin?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

They are not for the same purpose. css-minimizer-webpack-plugin is used to compress the css files produced by min-css-extract-plugin. Here is how thy are used (I am in webpack.config.js):

 //min-css-extract-plugin goes in the plugins array
 plugins: [
    new MiniCssExtractPlugin({
      filename:
        mode === "production"
          ? "css/[name].[contenthash].chunk.css"
          : "css/[name].css",
    }),
  ],
 //css-minimizer-webpack-plugin goes in the optimization object in minimizer array
 optimization:{
  minimizer: ["...", new CssMinimizerPlugin()],
 }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading