help: Pre compress astro build files before serving.

This way nginx doesn't have to compress it every time.
This commit is contained in:
Shubham Padia
2025-09-05 12:44:50 +00:00
committed by Alex Vandiver
parent 1a34016e4a
commit 57b7ada2e4
5 changed files with 18 additions and 5 deletions

9
pnpm-lock.yaml generated
View File

@@ -549,6 +549,9 @@ importers:
astro:
specifier: ^5.1.2
version: 5.13.5(@types/node@22.18.1)(encoding@0.1.13)(jiti@2.5.1)(rollup@4.50.0)(terser@5.44.0)(typescript@5.9.2)(yaml@2.8.1)
astro-compressor:
specifier: ^1.1.2
version: 1.1.2
hast-util-from-html:
specifier: ^2.0.3
version: 2.0.3
@@ -3265,6 +3268,10 @@ packages:
resolution: {integrity: sha512-LElXdjswlqjWrPpJFg1Fx4wpkOCxj1TDHlSV4PlaRxHGWko024xICaa97ZkMfs6DRKlCguiAI+rbXv5GWwXIkg==}
hasBin: true
astro-compressor@1.1.2:
resolution: {integrity: sha512-BsX6ypOkRff2g7e5vA47Vlpq9MfVxAo4pXzfkJvXTSzzrSYvf8m3e0lbyGK6eReSzWcAPXymOTIoooqDX1BTlA==}
engines: {node: '>=22.15.0 <23.0.0 || >=23.8.0'}
astro-eslint-parser@1.2.2:
resolution: {integrity: sha512-JepyLROIad6f44uyqMF6HKE2QbunNzp3mYKRcPoDGt0QkxXmH222FAFC64WTyQu2Kg8NNEXHTN/sWuUId9sSxw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
@@ -12948,6 +12955,8 @@ snapshots:
astring@1.9.0: {}
astro-compressor@1.1.2: {}
astro-eslint-parser@1.2.2:
dependencies:
'@astrojs/compiler': 2.12.2

View File

@@ -36,10 +36,7 @@ location ~ ^(/help(?:/[^/]+)*)/+$ {
location /help {
alias $help_alias;
gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_static on;
include /etc/nginx/zulip-include/headers;
add_header Access-Control-Allow-Origin *;
add_header Timing-Allow-Origin *;

View File

@@ -4,6 +4,7 @@ import * as fs from "node:fs";
import starlight from "@astrojs/starlight";
import {defineConfig, envField} from "astro/config";
import compressor from "astro-compressor";
import Icons from "unplugin-icons/vite";
// https://astro.build/config
@@ -73,6 +74,11 @@ export default defineConfig({
},
},
integrations: [
compressor({
gzip: true,
brotli: false,
zstd: false,
}),
starlight({
title: "Zulip help center",
favicon: "../static/images/favicon.svg",

View File

@@ -14,6 +14,7 @@
"@astrojs/starlight": "^0.35.1",
"@iconify-json/fa": "^1.2.1",
"astro": "^5.1.2",
"astro-compressor": "^1.1.2",
"hast-util-from-html": "^2.0.3",
"hast-util-to-html": "^9.0.5",
"mdast-util-to-string": "^4.0.0",

View File

@@ -49,4 +49,4 @@ API_FEATURE_LEVEL = 425
# historical commits sharing the same major version, in which case a
# minor version bump suffices.
PROVISION_VERSION = (348, 0) # bumped 2025-09-10 to downgrade sharp
PROVISION_VERSION = (348, 1) # bumped 2025-09-10 to add astro-compressor.