Full Changelog: https://github.com/PlayForm/Compress/compare/AstroCompress/v2.4.2...AstroCompress/v2.4.3
Compress
PlayFormCC0-1.0活跃维护Astro 集成插件,在构建时自动压缩 HTML、CSS、JavaScript 和图片,减少产物体积、加快页面加载。
Compress 🗜️
npx astro add @playform/compress
yarn astro add @playform/compress
npm install -D -E @playform/compressREADME 没有说明硬件要求。
项目说明
这个项目的说明还在生成中,先参考下面「最近发版」和 README。
- AstroCompress/v2.4.32026-08-07 · 2026-08-07 02:42 UTC
查看更新说明
- Compress/v0.2.5最新正式版2026-08-07 · 2026-08-07 02:00 UTC
- AstroCompress/v2.4.22026-08-05 · 2026-08-05 13:56 UTC
查看更新说明
What's Changed
- Bump dependabot/fetch-metadata from 2.5.0 to 3.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/596
- Bump actions/upload-artifact from 6.0.0 to 7.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/597
- Bump actions/setup-node from 6.1.0 to 6.3.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/599
- Bump pnpm/action-setup from 4.2.0 to 5.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/598
- Bump actions/checkout from 6.0.1 to 6.0.2 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/600
- Bump actions/upload-artifact from 7.0.0 to 7.0.1 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/601
- Bump dependabot/fetch-metadata from 3.0.0 to 3.1.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/603
- Bump pnpm/action-setup from 5.0.0 to 6.0.1 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/604
- Bump actions/setup-node from 6.3.0 to 6.4.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/605
- Bump pnpm/action-setup from 6.0.1 to 6.0.3 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/606
- Bump pozil/auto-assign-issue from 2.2.0 to 3.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/607
- Bump terser from 5.46.1 to 5.46.2 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/608
- Bump pnpm/action-setup from 6.0.3 to 6.0.4 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/609
- Bump pnpm/action-setup from 6.0.4 to 6.0.5 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/610
- Bump terser from 5.46.2 to 5.47.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/611
- Bump terser from 5.47.0 to 5.47.1 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/613
- Bump pnpm/action-setup from 6.0.5 to 6.0.7 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/614
- Bump pnpm/action-setup from 6.0.7 to 6.0.8 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/615
- Bump terser from 5.47.1 to 5.48.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/616
- Update astro requirement from ^6.3.7 to ^6.3.8 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/617
- Bump commander from 14.0.3 to 15.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/621
- Bump pozil/auto-assign-issue from 3.0.0 to 4.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/623
- Bump actions/checkout from 6.0.2 to 6.0.3 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/622
- Bump sharp from 0.34.5 to 0.35.2 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/629
- Bump sharp from 0.35.2 to 0.35.3 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/631
- Bump browserslist from 4.28.2 to 4.28.4 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/630
- Bump actions/checkout from 6.0.3 to 7.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/628
- Bump pnpm/action-setup from 6.0.8 to 6.0.9 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/627
- Bump pozil/auto-assign-issue from 4.0.0 to 4.0.1 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/625
- Bump browserslist from 4.28.4 to 4.28.5 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/632
- Bump terser from 5.48.0 to 5.49.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/633
- Bump browserslist from 4.28.5 to 4.28.6 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/635
- Bump svgo from 4.0.1 to 4.0.2 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/634
- Bump actions/setup-node from 6.4.0 to 7.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/636
- Bump @playform/build from 0.3.2 to 0.3.3 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/638
- Compress/v0.2.42026-08-05 · 2026-08-05 13:02 UTC
查看更新说明
What's Changed
- Bump dependabot/fetch-metadata from 2.5.0 to 3.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/596
- Bump actions/upload-artifact from 6.0.0 to 7.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/597
- Bump actions/setup-node from 6.1.0 to 6.3.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/599
- Bump pnpm/action-setup from 4.2.0 to 5.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/598
- Bump actions/checkout from 6.0.1 to 6.0.2 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/600
- Bump actions/upload-artifact from 7.0.0 to 7.0.1 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/601
- Bump dependabot/fetch-metadata from 3.0.0 to 3.1.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/603
- Bump pnpm/action-setup from 5.0.0 to 6.0.1 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/604
- Bump actions/setup-node from 6.3.0 to 6.4.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/605
- Bump pnpm/action-setup from 6.0.1 to 6.0.3 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/606
- Bump pozil/auto-assign-issue from 2.2.0 to 3.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/607
- Bump terser from 5.46.1 to 5.46.2 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/608
- Bump pnpm/action-setup from 6.0.3 to 6.0.4 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/609
- Bump pnpm/action-setup from 6.0.4 to 6.0.5 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/610
- Bump terser from 5.46.2 to 5.47.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/611
- Bump terser from 5.47.0 to 5.47.1 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/613
- Bump pnpm/action-setup from 6.0.5 to 6.0.7 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/614
- Bump pnpm/action-setup from 6.0.7 to 6.0.8 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/615
- Bump terser from 5.47.1 to 5.48.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/616
- Update astro requirement from ^6.3.7 to ^6.3.8 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/617
- Bump commander from 14.0.3 to 15.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/621
- Bump pozil/auto-assign-issue from 3.0.0 to 4.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/623
- Bump actions/checkout from 6.0.2 to 6.0.3 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/622
- Bump sharp from 0.34.5 to 0.35.2 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/629
- Bump sharp from 0.35.2 to 0.35.3 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/631
- Bump browserslist from 4.28.2 to 4.28.4 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/630
- Bump actions/checkout from 6.0.3 to 7.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/628
- Bump pnpm/action-setup from 6.0.8 to 6.0.9 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/627
- Bump pozil/auto-assign-issue from 4.0.0 to 4.0.1 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/625
- Bump browserslist from 4.28.4 to 4.28.5 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/632
- Bump terser from 5.48.0 to 5.49.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/633
- Bump browserslist from 4.28.5 to 4.28.6 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/635
- Bump svgo from 4.0.1 to 4.0.2 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/634
- Bump actions/setup-node from 6.4.0 to 7.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/636
- Bump @playform/build from 0.3.2 to 0.3.3 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/638
- Bump lightningcss from 1.32.0 to 1.
- Compress/v0.2.32026-04-07 · 2026-04-07 14:00 UTC
查看更新说明
What's Changed
- Bump pnpm/action-setup from 4.2.0 to 4.3.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/586
- Bump pnpm/action-setup from 4.3.0 to 4.4.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/589
- Bump terser from 5.46.0 to 5.46.1 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/590
- Bump pnpm/action-setup from 4.4.0 to 5.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/591
- Bump actions/upload-artifact from 6.0.0 to 7.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/588
- Bump actions/setup-node from 6.2.0 to 6.3.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/587
- Bump dependabot/fetch-metadata from 2.5.0 to 3.0.0 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/592
- Bump browserslist from 4.28.1 to 4.28.2 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/594
- Bump @playform/build from 0.3.0 to 0.3.1 by @dependabot[bot] in https://github.com/PlayForm/Compress/pull/595
Full Changelog: https://github.com/PlayForm/Compress/compare/Compress/v0.2.2...Compress/v0.2.3
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Compress 🗜️
This Astro integration brings compression utilities
to your Astro project.
JSON 🎁
Note
Compresswill not compress your requests, only your statically generated build and pre-rendered routes.
[!IMPORTANT]
Use
Compresslast in your integration list for the best optimizations.
Installation 🚀
There are two ways to add integrations to your project. Let's try the most convenient option first!
astro add command
Astro includes a CLI tool for adding first party integrations: astro add. This
command will:
- (Optionally) Install all necessary dependencies and peer dependencies
- (Also optionally) Update your
astro.config.*file to apply this integration
To install Compress, run the following from your project directory and follow
the prompts:
Using NPM:
npx astro add @playform/compress
Using Yarn:
yarn astro add @playform/compress
Using PNPM:
pnpx astro add @playform/compress
Install dependencies manually
First, install the Compress integration like so:
npm install -D -E @playform/compress
Then, apply this integration to your astro.config.* file using the
integrations property:
astro.config.ts
export default {
integrations: [(await import("@playform/compress")).default()],
};
Getting started
The utility will now automatically compress all your CSS, HTML, SVG, JavaScript,
JSON and image files in the Astro outDir folder.
The following image file types will be compressed via sharp:
- avci
- avcs
- avif
- avifs
- gif
- heic
- heics
- heif
- heifs
- jfif
- jif
- jpe
- jpeg
- jpg
- apng
- png
- raw
- tiff
- webp
SVG compression is supported, as well via svgo.
Default Compression
You can override any of the default options from the configurations of:
[!IMPORTANT]
lightningcssis the default CSS compressor andcssois disabled by default.cssosilently deletes modern CSS it cannot parse rather than leaving it untouched — Media Queries Level 4 range syntax (@media (width>=40rem), which Tailwind CSS v4 emits for every responsive breakpoint) and CSS nesting blocks are dropped from the output with no error or warning.
If you still want csso, enable it explicitly — and be aware it runs after
lightningcss, so it can undo what lightningcss correctly preserved:
astro.config.ts
export default {
integrations: [
(await import("@playform/compress")).default({
CSS: {
csso: true,
lightningcss: true,
},
}),
],
};
astro.config.ts
export default {
integrations: [
(await import("@playform/compress")).default({
CSS: false,
HTML: {
"html-minifier-terser": {
removeAttributeQuotes: false,
},
},
Image: false,
JavaScript: false,
JSON: false,
SVG: false,
}),
],
};
or disable them entirely:
astro.config.ts
export default {
integrations: [
(await import("@playform/compress")).default({
CSS: false,
HTML: false,
Image: false,
JavaScript: false,
JSON: false,
SVG: false,
}),
],
};
You can see the full option map here:
Source/Interface/Option.ts
Output
By default Compress compresses the outDir Astro directory, if you'd like
it to compress a different directory you would have to add it to the Compress
Path option, as well:
export default {
integrations: [
(await import("@playform/compress")).default({
Path: ["./dist", "./Compress"],
}),
],
};
Add Multiple Paths
You can add multiple paths to compress by specifying an array as the Path
variable.
astro.config.ts
export default {
integrations: [
(await import("@playform/compress")).default({
Path: ["./Target", "./Build"],
}),
],
};
Input-Output Mapping
You can also provide a map of paths for different input output directories.
astro.config.ts
export default {
integrations: [
(await import("@playform/compress")).default({
Path: new Map([["./Source", "./Target"]]),
}),
],
};
Or an array of the two:
astro.config.ts
export default {
integrations: [
(await import("@playform/compress")).default({
Path: [
// Compress Target
"./Target",
// Compress Target one more time into a different directory
new Map([["./Target", "./TargetCompress"]]),
],
}),
],
};
File Filtering
You can filter files to exclude specific ones from compression. A filter can be an array of regular expressions or a single match. You can also use functions to match on file names:
astro.config.ts
export default {
integrations: [
(await import("@playform/compress")).default({
Exclude: [
"File.png",
(File: string) =>
File === "./Target/Favicon/Image/safari-pinned-tab.svg",
],
}),
],
};
Controlling Logging
You can control the logging level by setting the Logger parameter. The default
value is 2, but you can set it to 0 if you don't want to see debug messages:
astro.config.ts
export default {
integrations: [
(await import("@playform/compress")).default({
Logger: 0,
}),
],
};
Changelog
See CHANGELOG.md for a history of changes to this integration.