fix: 禁用Astro图片优化功能并添加补丁配置

添加astro.patch文件禁用图片优化功能,修改package.json和pnpm-lock.yaml以支持补丁依赖
This commit is contained in:
二叉树树
2025-09-10 06:11:21 +08:00
parent 64f2434b81
commit 09af20cb1a
3 changed files with 54 additions and 15 deletions

29
patches/astro.patch Normal file
View File

@@ -0,0 +1,29 @@
diff --git a/dist/assets/utils/transformToPath.js b/dist/assets/utils/transformToPath.js
index cca8548dec42090b0621d1f21c86f503d5bba1be..8b0a3cfcea73abc4d63592709bb9ba2b2f83989a 100644
--- a/dist/assets/utils/transformToPath.js
+++ b/dist/assets/utils/transformToPath.js
@@ -13,7 +13,9 @@ function propsToFilename(filePath, transform, hash) {
}
const prefixDirname = isESMImportedImage(transform.src) ? dirname(filePath) : "";
let outputExt = transform.format ? `.${transform.format}` : ext;
- return decodeURIComponent(`${prefixDirname}/${filename}_${hash}${outputExt}`);
+
+ // Force disable image optimization - return original path without hash and format conversion
+ return decodeURIComponent(`${prefixDirname}/${filename}${ext}`);
}
function hashTransform(transform, imageService, propertiesToHash) {
const hashFields = propertiesToHash.reduce(
diff --git a/dist/core/build/generate.js b/dist/core/build/generate.js
index 3144f4c058b161b9e6eb3c8d891b743b34783653..0ba275b320204e154307c6aff75452e9dcb2300d 100644
--- a/dist/core/build/generate.js
+++ b/dist/core/build/generate.js
@@ -91,7 +91,8 @@ ${bgGreen(black(` ${verb} static routes `))}`);
`)
);
const staticImageList = getStaticImageList();
- if (staticImageList.size) {
+ // Force disable image optimization - hardcoded
+ if (false) {
logger.info("SKIP_FORMAT", `${bgGreen(black(` generating optimized images `))}`);
const totalCount = Array.from(staticImageList.values()).map((x) => x.transforms.size).reduce((a, b) => a + b, 0);
const cpuCount = os.cpus().length;