百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

compression-webpack-plugin

> 编程语言
开源

准备资产的压缩版本,并使用 Content-Encoding 来服务这些资产

1.4K stars0 点赞1 次浏览
访问官网GitHub

工具介绍

准备资产的压缩版本,并使用 Content-Encoding 来服务这些资产

[![npm][npm]][npm-url] [![node][node]][node-url] [![测试][tests]][tests-url] [![cover][cover]][cover-url] [![讨论][discussion]][discussion-url] [![size][size]][size-url]

compression-webpack-plugin

准备资产的压缩版本,使用 Content-Encoding 来服务这些资产。

开始使用

首先,您需要安装 compression-webpack-plugin:

bash
npm install compression-webpack-plugin --save-dev

或者

bash
yarn add -D compression-webpack-plugin

或者

bash
pnpm add -D compression-webpack-plugin

然后将插件添加到您的 webpack 配置中。例如: webpack.config.js

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

module.exports = {
  plugins: [new CompressionPlugin()],
};

最后,使用您通常使用的方法(例如,通过 CLI 或 npm 脚本)运行 webpack。

选项

test

类型:ts type test = string | RegExp | (string | RegExp)[]; 默认值:undefined 包含所有通过测试断言的资源。

webpack.config.js

javascript
module.exports = {
  plugins: [
    new CompressionPlugin({
      exclude: /\/excludes/,
    }),
  ],
};

algorithm

类型:

…

定义要使用的压缩算法或函数。默认为 gzip。

[! 注意]

我

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScriptwebpack-plugin

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言