Webpack packing Times error

clipboard.png

this is my configuration

if (config.build.productionGzip) {
  const CompressionWebpackPlugin = require("compression-webpack-plugin")
  webpackConfig.plugins.push(
    new CompressionWebpackPlugin({
      asset: "[path].gz[query]",
      algorithm: "gzip",
      test: new RegExp(
        "\\.(" +
        config.build.productionGzipExtensions.join("|") +
        ")$"
      ),
      threshold: 10240,
      minRatio: 0.8
    })
  )
}

compression-webpack-plugin ValidationError: Compression Plugin Invalid Options

when you see this error, you can check the parameters carefully, and you can also go to the official website to check the parameter information and don"t find anything wrong. I don"t know what to do with it.


Hello, landlord! First of all, confirm what version of compression-webpack-plugin you installed? If it is the 1.x version, there will be no problem with the parameters as you write. If it is the 2.x version, then the parameter asset must be replaced with filename . A personal test is fine. Attach the document address: https://github.com/webpack-co.. You can check it yourself.


there is no asset configuration on the document. It is superfluous and needs to be removed. Reading the document means that you need to use filename instead of


landlord. Hello, how did you solve it? I also encountered the same question


found the answer, according to the method in this blog, install the plug-in with the version number and configure it successfully. https://www.cnblogs.com/dongh.

Menu