From 09af20cb1ad9ae6d498d7fba7fc7f936b1ff1e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E5=8F=89=E6=A0=91=E6=A0=91?= Date: Wed, 10 Sep 2025 06:11:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A6=81=E7=94=A8Astro=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E4=BC=98=E5=8C=96=E5=8A=9F=E8=83=BD=E5=B9=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=A1=A5=E4=B8=81=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加astro.patch文件禁用图片优化功能,修改package.json和pnpm-lock.yaml以支持补丁依赖 --- package.json | 7 ++++++- patches/astro.patch | 29 +++++++++++++++++++++++++++++ pnpm-lock.yaml | 33 +++++++++++++++++++-------------- 3 files changed, 54 insertions(+), 15 deletions(-) create mode 100644 patches/astro.patch diff --git a/package.json b/package.json index 73c637468..0c2663008 100644 --- a/package.json +++ b/package.json @@ -76,5 +76,10 @@ "postcss-nesting": "^13.0.1", "rehype": "^13.0.2" }, - "packageManager": "pnpm@9.14.4" + "packageManager": "pnpm@9.14.4", + "pnpm": { + "patchedDependencies": { + "astro": "patches/astro.patch" + } + } } diff --git a/patches/astro.patch b/patches/astro.patch new file mode 100644 index 000000000..01c219f67 --- /dev/null +++ b/patches/astro.patch @@ -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; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fdb8bb73f..e60638075 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,11 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +patchedDependencies: + astro: + hash: ysrllw3gj6hylybllnynya5oma + path: patches/astro.patch + importers: .: @@ -19,13 +24,13 @@ importers: version: 3.3.1 '@astrojs/svelte': specifier: 7.0.12 - version: 7.0.12(@types/node@22.14.1)(astro@5.7.9(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0))(jiti@1.21.7)(lightningcss@1.29.3)(sass@1.80.4)(stylus@0.64.0)(svelte@5.28.2)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0) + version: 7.0.12(@types/node@22.14.1)(astro@5.7.9(patch_hash=ysrllw3gj6hylybllnynya5oma)(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0))(jiti@1.21.7)(lightningcss@1.29.3)(sass@1.80.4)(stylus@0.64.0)(svelte@5.28.2)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0) '@astrojs/tailwind': specifier: ^6.0.2 - version: 6.0.2(astro@5.7.9(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0))(tailwindcss@3.4.17) + version: 6.0.2(astro@5.7.9(patch_hash=ysrllw3gj6hylybllnynya5oma)(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0))(tailwindcss@3.4.17) '@astrojs/vercel': specifier: ^8.2.7 - version: 8.2.7(astro@5.7.9(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0))(rollup@2.79.2)(svelte@5.28.2) + version: 8.2.7(astro@5.7.9(patch_hash=ysrllw3gj6hylybllnynya5oma)(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0))(rollup@2.79.2)(svelte@5.28.2) '@expressive-code/core': specifier: ^0.41.3 version: 0.41.3 @@ -70,10 +75,10 @@ importers: version: 0.5.16(tailwindcss@3.4.17) astro: specifier: 5.7.9 - version: 5.7.9(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0) + version: 5.7.9(patch_hash=ysrllw3gj6hylybllnynya5oma)(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0) astro-expressive-code: specifier: ^0.41.3 - version: 0.41.3(astro@5.7.9(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0)) + version: 0.41.3(astro@5.7.9(patch_hash=ysrllw3gj6hylybllnynya5oma)(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0)) astro-icon: specifier: ^1.1.5 version: 1.1.5 @@ -5553,10 +5558,10 @@ snapshots: stream-replace-string: 2.0.0 zod: 3.24.3 - '@astrojs/svelte@7.0.12(@types/node@22.14.1)(astro@5.7.9(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0))(jiti@1.21.7)(lightningcss@1.29.3)(sass@1.80.4)(stylus@0.64.0)(svelte@5.28.2)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0)': + '@astrojs/svelte@7.0.12(@types/node@22.14.1)(astro@5.7.9(patch_hash=ysrllw3gj6hylybllnynya5oma)(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0))(jiti@1.21.7)(lightningcss@1.29.3)(sass@1.80.4)(stylus@0.64.0)(svelte@5.28.2)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0)': dependencies: '@sveltejs/vite-plugin-svelte': 5.0.3(svelte@5.28.2)(vite@6.3.3(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(yaml@2.7.0)) - astro: 5.7.9(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0) + astro: 5.7.9(patch_hash=ysrllw3gj6hylybllnynya5oma)(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0) svelte: 5.28.2 svelte2tsx: 0.7.36(svelte@5.28.2)(typescript@5.8.3) typescript: 5.8.3 @@ -5575,9 +5580,9 @@ snapshots: - tsx - yaml - '@astrojs/tailwind@6.0.2(astro@5.7.9(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0))(tailwindcss@3.4.17)': + '@astrojs/tailwind@6.0.2(astro@5.7.9(patch_hash=ysrllw3gj6hylybllnynya5oma)(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0))(tailwindcss@3.4.17)': dependencies: - astro: 5.7.9(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0) + astro: 5.7.9(patch_hash=ysrllw3gj6hylybllnynya5oma)(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0) autoprefixer: 10.4.21(postcss@8.5.3) postcss: 8.5.3 postcss-load-config: 4.0.2(postcss@8.5.3) @@ -5607,14 +5612,14 @@ snapshots: semver: 7.7.1 vscode-languageserver-textdocument: 1.0.12 - '@astrojs/vercel@8.2.7(astro@5.7.9(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0))(rollup@2.79.2)(svelte@5.28.2)': + '@astrojs/vercel@8.2.7(astro@5.7.9(patch_hash=ysrllw3gj6hylybllnynya5oma)(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0))(rollup@2.79.2)(svelte@5.28.2)': dependencies: '@astrojs/internal-helpers': 0.7.2 '@vercel/analytics': 1.5.0(svelte@5.28.2) '@vercel/functions': 2.2.13 '@vercel/nft': 0.29.4(rollup@2.79.2) '@vercel/routing-utils': 5.1.1 - astro: 5.7.9(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0) + astro: 5.7.9(patch_hash=ysrllw3gj6hylybllnynya5oma)(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0) esbuild: 0.25.3 tinyglobby: 0.2.13 transitivePeerDependencies: @@ -7514,9 +7519,9 @@ snapshots: get-intrinsic: 1.3.0 is-array-buffer: 3.0.5 - astro-expressive-code@0.41.3(astro@5.7.9(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0)): + astro-expressive-code@0.41.3(astro@5.7.9(patch_hash=ysrllw3gj6hylybllnynya5oma)(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0)): dependencies: - astro: 5.7.9(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0) + astro: 5.7.9(patch_hash=ysrllw3gj6hylybllnynya5oma)(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0) rehype-expressive-code: 0.41.3 astro-icon@1.1.5: @@ -7528,7 +7533,7 @@ snapshots: - debug - supports-color - astro@5.7.9(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0): + astro@5.7.9(patch_hash=ysrllw3gj6hylybllnynya5oma)(@types/node@22.14.1)(jiti@1.21.7)(lightningcss@1.29.3)(rollup@2.79.2)(sass@1.80.4)(stylus@0.64.0)(terser@5.39.0)(typescript@5.8.3)(yaml@2.7.0): dependencies: '@astrojs/compiler': 2.11.0 '@astrojs/internal-helpers': 0.6.1