compression-webpack-plugin GZip插件打包报错 ValidationError: Compression Plugin Invalid Options

在使用compression-webpack-plugin进行GZip压缩时遇到错误:ValidationError: Compression Plugin Invalid Options。安装并配置插件后,执行打包操作报错。通过检查配置和重新执行,问题得到解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装插件: yarn add compression-webpack-plugin
配置webpack.js

const CompressionPlugin = require("compression-webpack-plugin");

return (
	plugins: [
	      new BundleAnalyzerPlugin(),
	      isEnvProduction && new 
FATAL Invalid options object. Compression Plugin has been initialized using an options object that does not match the API schema. 14:54:53 - options has an unknown property 'level'. These properties are valid: object { test?, include?, exclude?, algorithm?, compressionOptions?, threshold?, minRatio?, deleteOriginalAssets?, filename?, cache? } - options has an unknown property 'level'. These properties are valid: object { test?, include?, exclude?, algorithm?, compressionOptions?, threshold?, minRatio?, deleteOriginalAssets?, filename?, cache? } at validate (node_modules\compression-webpack-plugin\node_modules\schema-utils\dist\validate.js:98:11) at new CompressionPlugin (node_modules\compression-webpack-plugin\dist\index.js:32:30) at WebpackBundler.<anonymous> (node_modules\nuxt-precompress\lib\module.js:57:7) at next (node_modules\@nuxt\utils\dist\utils.js:659:27) at WebpackBundler.<anonymous> (node_modules\@nuxt\utils\dist\utils.js:674:12) at WebpackBundler.<anonymous> (node_modules\@nuxt\utils\dist\utils.js:668:29) at WebpackClientConfig.extendConfig (node_modules\@nuxt\webpack\dist\webpack.js:1509:37) at WebpackClientConfig.config (node_modules\@nuxt\webpack\dist\webpack.js:1544:50) at WebpackClientConfig.config (node_modules\@nuxt\webpack\dist\webpack.js:1708:26) at WebpackBundler.getWebpackConfig (node_modules\@nuxt\webpack\dist\webpack.js:2016:19) at WebpackBundler.build (node_modules\@nuxt\webpack\dist\webpack.js:2023:12) at Builder.build (node_modules\@nuxt\builder\dist\builder.js:327:30) at async Object.run (node_modules\@nuxt\cli\dist\cli-build.js:110:7) at async NuxtCommand.run (node_modules\@nuxt\cli\dist\cli-index.js:413:7) ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ │ │ ✖ Nuxt Fatal Error │ │ │ │ ValidationError: Invalid options object. Compression Plugin has been initialized using an options object that does not match the API schema. │ │ - options has an unknown property 'level'. These properties are valid: │ │ object { test?, include?, exclude?, algorithm?, compressionOptions?, threshold?, minRatio?, deleteOriginalAssets?, filename?, cache? } │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! f11-web-new@1.0.0 build: `nuxt build` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the f11-web-new@1.0.0 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\ZXJ\AppData\Roaming\npm-cache\_logs\2025-08-06T06_54_53_561Z-debug.log
最新发布
08-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值