astro-precompressor 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -18
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -15,7 +15,8 @@ avoid unnecessary recompression between builds (the main motivation for building
|
|
|
15
15
|
this integration) and supports configurable algorithms, file filtering, and
|
|
16
16
|
performance.
|
|
17
17
|
|
|
18
|
-
> [!IMPORTANT]
|
|
18
|
+
> [!IMPORTANT]
|
|
19
|
+
> For this integration to be useful, your hosting environment must
|
|
19
20
|
> be set up for serving precompressed sidecars. See
|
|
20
21
|
> [Configuring Your Hosting Environment](#configuring-your-hosting-environment)
|
|
21
22
|
> for suggestions on how to do this.
|
|
@@ -54,7 +55,8 @@ build, you should see compression statistics in your build output.
|
|
|
54
55
|
16:40:30 [astro-precompressor] Done!
|
|
55
56
|
```
|
|
56
57
|
|
|
57
|
-
> [!NOTE]
|
|
58
|
+
> [!NOTE]
|
|
59
|
+
> 'combined processing time' refers to the combined processing time of
|
|
58
60
|
> all compression tasks. Since these tasks run in parallel, the actual time
|
|
59
61
|
> taken for them all to complete will typically be much shorter depending on
|
|
60
62
|
> your concurrency value.
|
|
@@ -128,7 +130,8 @@ pnpm add -D node-zopfli-es
|
|
|
128
130
|
yarn add -D node-zopfli-es
|
|
129
131
|
```
|
|
130
132
|
|
|
131
|
-
> [!TIP]
|
|
133
|
+
> [!TIP]
|
|
134
|
+
> The default zopfli settings used by `astro-precompressor` have been
|
|
132
135
|
> tuned for speed without sacrificing compression. If smaller gzip files are a
|
|
133
136
|
> priority, installing `node-zopfli-es` alongside `astro-precompressor` is
|
|
134
137
|
> highly recommended. See the Gzip section under
|
|
@@ -152,7 +155,8 @@ export default defineConfig({
|
|
|
152
155
|
})
|
|
153
156
|
```
|
|
154
157
|
|
|
155
|
-
> [!CAUTION]
|
|
158
|
+
> [!CAUTION]
|
|
159
|
+
> Astro runs integrations in the order they are listed. To avoid
|
|
156
160
|
> subsequent integrations from affecting compressed files, and to ensure any
|
|
157
161
|
> files created or modified by other integrations are compressed appropriately,
|
|
158
162
|
> always ensure that this integration sits last in the list.
|
|
@@ -210,7 +214,8 @@ algorithms: {
|
|
|
210
214
|
}
|
|
211
215
|
```
|
|
212
216
|
|
|
213
|
-
> [!NOTE]
|
|
217
|
+
> [!NOTE]
|
|
218
|
+
> The `constants` object used in the algorithm configurations below
|
|
214
219
|
> comes from the `node:zlib` package.
|
|
215
220
|
|
|
216
221
|
**Gzip**
|
|
@@ -246,7 +251,8 @@ gzip: {
|
|
|
246
251
|
}
|
|
247
252
|
```
|
|
248
253
|
|
|
249
|
-
> [!TIP]
|
|
254
|
+
> [!TIP]
|
|
255
|
+
> While higher `numiterations` can produce smaller file sizes, it does so
|
|
250
256
|
> at the expense of speed. In testing representative minified Astro output
|
|
251
257
|
> files, setting it to `5` produced files that were identical in size to `15`
|
|
252
258
|
> (the engine default) while being three times faster. `blocksplitting` has also
|
|
@@ -308,7 +314,8 @@ zstd: {
|
|
|
308
314
|
}
|
|
309
315
|
```
|
|
310
316
|
|
|
311
|
-
> [!CAUTION]
|
|
317
|
+
> [!CAUTION]
|
|
318
|
+
> 19 is the highest standard compression level. Setting this higher
|
|
312
319
|
> (20–22) turns on ultra mode which is significantly more compute-intensive. If
|
|
313
320
|
> you experiment with these higher levels, consider reducing the
|
|
314
321
|
> `performance.concurrency` option to a conservative value, such as 1, and
|
|
@@ -335,7 +342,8 @@ cache: {
|
|
|
335
342
|
| ------- | ------------------------------------------------------ |
|
|
336
343
|
| `prune` | Remove obsolete cached artifacts and manifest entries. |
|
|
337
344
|
|
|
338
|
-
> [!NOTE]
|
|
345
|
+
> [!NOTE]
|
|
346
|
+
> Prior to v1.2.0, the `prune` option was controlled by setting
|
|
339
347
|
> `pruneCache` under the `filters` property. It has been moved to its own group
|
|
340
348
|
> for clarity.
|
|
341
349
|
|
|
@@ -450,7 +458,8 @@ filters: {
|
|
|
450
458
|
A string pattern applies to all globally enabled algorithms. An object pattern
|
|
451
459
|
applies only to the algorithms listed in its `algorithms` array.
|
|
452
460
|
|
|
453
|
-
> [!IMPORTANT]
|
|
461
|
+
> [!IMPORTANT]
|
|
462
|
+
> The top-level `algorithms` and `filters.fileTypes` options are
|
|
454
463
|
> authoritative. Glob filters can restrict which globally enabled algorithms are
|
|
455
464
|
> used for a file, but cannot enable an algorithm that is globally disabled.
|
|
456
465
|
> Likewise, include patterns cannot make a filetype eligible if it is excluded
|
|
@@ -496,7 +505,8 @@ passes the `fileTypes` and `minSize` filters.
|
|
|
496
505
|
| Any matching include pattern | String pattern | File excluded |
|
|
497
506
|
| Include patterns configured, but none match | None | File skipped |
|
|
498
507
|
|
|
499
|
-
> [!NOTE]
|
|
508
|
+
> [!NOTE]
|
|
509
|
+
> The resulting algorithms are always limited to those enabled in the
|
|
500
510
|
> top-level `algorithms` configuration. If no algorithms remain after applying
|
|
501
511
|
> the matching rules, the file is skipped.
|
|
502
512
|
|
|
@@ -527,7 +537,8 @@ In this example, HTML files receive every globally enabled algorithm, CSS files
|
|
|
527
537
|
receive Gzip only, and SVG files receive every globally enabled algorithm except
|
|
528
538
|
Gzip. Files beneath `drafts/` are excluded entirely.
|
|
529
539
|
|
|
530
|
-
> [!TIP]
|
|
540
|
+
> [!TIP]
|
|
541
|
+
> Because files only need to match one include pattern, adding `**` or
|
|
531
542
|
> `'**/**'` (which match all file paths) to the include list causes all
|
|
532
543
|
> otherwise eligible files pass the include filter, regardless of any other
|
|
533
544
|
> include patterns specified.
|
|
@@ -545,7 +556,8 @@ performance: {
|
|
|
545
556
|
}
|
|
546
557
|
```
|
|
547
558
|
|
|
548
|
-
> [!NOTE]
|
|
559
|
+
> [!NOTE]
|
|
560
|
+
> `availableParallelism` comes from the `node:os` package
|
|
549
561
|
|
|
550
562
|
| Option | Description |
|
|
551
563
|
| ---------------------------- | -------------------------------------------------------------------------------------------- |
|
|
@@ -642,7 +654,8 @@ When `logLevel` is set to `2`, debug messages will only be shown when the
|
|
|
642
654
|
the same output as `logLevel: 1`. The default level is `2` to match Astro's own
|
|
643
655
|
logging conventions.
|
|
644
656
|
|
|
645
|
-
> [!TIP]
|
|
657
|
+
> [!TIP]
|
|
658
|
+
> Set this value to 0 if you prefer concise logs.
|
|
646
659
|
|
|
647
660
|
## Build Lifecycle
|
|
648
661
|
|
|
@@ -654,13 +667,15 @@ The integration uses Astro's build lifecycle hooks:
|
|
|
654
667
|
- `astro:build:done`: Processes the completed build output and generates
|
|
655
668
|
compressed artifacts.
|
|
656
669
|
|
|
657
|
-
> [!WARNING]
|
|
670
|
+
> [!WARNING]
|
|
671
|
+
> If zopfli is explicitly enabled in your configuration without
|
|
658
672
|
> `node-zopfli-es` being installed, your Astro build will fail at the setup
|
|
659
673
|
> stage.
|
|
660
674
|
|
|
661
675
|
## Configuring Your Hosting Environment
|
|
662
676
|
|
|
663
|
-
> [!IMPORTANT]
|
|
677
|
+
> [!IMPORTANT]
|
|
678
|
+
> Generating compressed sidecars does not automatically configure
|
|
664
679
|
> your hosting environment to serve them. Your web server, CDN, or hosting
|
|
665
680
|
> provider must support content negotiation and serve the appropriate sidecar
|
|
666
681
|
> when a client advertises support for the algorithm.
|
|
@@ -715,10 +730,12 @@ RewriteRule \.eot\.(br|gz)$ - [T=application/vnd.ms-fontobject,E=no-brotli:1,E=n
|
|
|
715
730
|
</FilesMatch>
|
|
716
731
|
```
|
|
717
732
|
|
|
718
|
-
> [!TIP]
|
|
733
|
+
> [!TIP]
|
|
734
|
+
> Adjust the filetypes above to match your `astro-precompressor`
|
|
719
735
|
> configuration.
|
|
720
736
|
|
|
721
|
-
> [!WARNING]
|
|
737
|
+
> [!WARNING]
|
|
738
|
+
> The `.htaccess` configuration above is representative and does not
|
|
722
739
|
> guard against a missing `mod_rewrite`. It assumes `mod_headers` and `mod_mime`
|
|
723
740
|
> are available. The encoding conditions reject explicitly disabled encodings
|
|
724
741
|
> (q=0), but do not implement complete quality-value negotiation or wildcard
|
|
@@ -752,7 +769,8 @@ server {
|
|
|
752
769
|
}
|
|
753
770
|
```
|
|
754
771
|
|
|
755
|
-
> [!IMPORTANT]
|
|
772
|
+
> [!IMPORTANT]
|
|
773
|
+
> Zstandard support is not included as standard in many Nginx
|
|
756
774
|
> installations. A separately built or third-party module may be required when
|
|
757
775
|
> using this algorithm in your environment.
|
|
758
776
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-precompressor",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Precompresses Astro output document files to Brotli (.br), Gzip (.gz) and optionally Zstandard (.zst)",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -66,11 +66,11 @@
|
|
|
66
66
|
"@types/node": "^26.6.6",
|
|
67
67
|
"@types/node-zopfli-es": "^0.0.4",
|
|
68
68
|
"@types/picomatch": "^4.0.3",
|
|
69
|
-
"@vitest/coverage-v8": "^5.1.
|
|
70
|
-
"astro": "7.4.
|
|
69
|
+
"@vitest/coverage-v8": "^5.1.1",
|
|
70
|
+
"astro": "7.4.13",
|
|
71
71
|
"node-zopfli-es": "^2.0.6",
|
|
72
72
|
"typescript": "^7.0.2",
|
|
73
|
-
"vitest": "^5.1.
|
|
73
|
+
"vitest": "^5.1.1",
|
|
74
74
|
"zstd-napi": ">=0.0.12"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|