Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

help: Fall back to unoptimized images if sharp cannot load.

Alex Vandiver8572aca4bc95
diff --git a/starlight_help/astro.config.mjs b/starlight_help/astro.config.mjs
index 51d312eff40..21587b79ae2 100644
--- a/starlight_help/astro.config.mjs
+++ b/starlight_help/astro.config.mjs
@@ -3,7 +3,7 @@
import * as fs from "node:fs";
import starlight from "@astrojs/starlight";
-import {defineConfig, envField} from "astro/config";
+import {defineConfig, envField, passthroughImageService} from "astro/config";
import compressor from "astro-compressor";
import Icons from "unplugin-icons/vite";
@@ -79,9 +79,22 @@ function createRedirectPlugin() {
};
}
+let sharpAvailable = true;
+try {
+ await import("sharp");
+} catch (error) {
+ // Prebuilt sharp binaries require an x86-64-v2 CPU, which older
+ // hardware and some virtual machine CPU models lack.
+ console.warn(
+ `Could not load sharp; help center images will not be optimized.\n${String(error)}`,
+ );
+ sharpAvailable = false;
+}
+
// https://astro.build/config
export default defineConfig({
base: "help",
+ image: sharpAvailable ? {} : {service: passthroughImageService()},
compressHTML: "jsx",
trailingSlash: "never",
vite: {