From 4be79cafdc3d0bf8cb872b14634e69e88f384df2 Mon Sep 17 00:00:00 2001 From: CC11001100 Date: Mon, 19 May 2025 02:38:00 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0CopyWebpackPlugin?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=9D=99=E6=80=81=E8=B5=84=E6=BA=90=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加copy-webpack-plugin依赖 - 配置webpack复制public/images到dist/images目录 - 解决GitHub Pages部署中图片404问题 --- script-hook-website/package-lock.json | 83 +++++++++++++++++++++++++++ script-hook-website/webpack.config.js | 10 ++++ 2 files changed, 93 insertions(+) diff --git a/script-hook-website/package-lock.json b/script-hook-website/package-lock.json index 23a35b3..3294fa1 100644 --- a/script-hook-website/package-lock.json +++ b/script-hook-website/package-lock.json @@ -28,6 +28,7 @@ }, "devDependencies": { "@types/react-syntax-highlighter": "^15.5.13", + "copy-webpack-plugin": "^13.0.0", "css-loader": "^6.7.3", "gh-pages": "^6.3.0", "html-webpack-plugin": "^5.5.1", @@ -1698,6 +1699,43 @@ "dev": true, "license": "MIT" }, + "node_modules/copy-webpack-plugin": { + "version": "13.0.0", + "resolved": "https://registry.npmmirror.com/copy-webpack-plugin/-/copy-webpack-plugin-13.0.0.tgz", + "integrity": "sha512-FgR/h5a6hzJqATDGd9YG41SeDViH+0bkHn6WNXCi5zKAZkeESeSxLySSsFLHqLEVCh0E+rITmCf0dusXWYukeQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "glob-parent": "^6.0.1", + "normalize-path": "^3.0.0", + "schema-utils": "^4.2.0", + "serialize-javascript": "^6.0.2", + "tinyglobby": "^0.2.12" + }, + "engines": { + "node": ">= 18.12.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^5.1.0" + } + }, + "node_modules/copy-webpack-plugin/node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmmirror.com/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmmirror.com/core-util-is/-/core-util-is-1.0.3.tgz", @@ -5874,6 +5912,51 @@ "dev": true, "license": "MIT" }, + "node_modules/tinyglobby": { + "version": "0.2.13", + "resolved": "https://registry.npmmirror.com/tinyglobby/-/tinyglobby-0.2.13.tgz", + "integrity": "sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.4.4", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinyglobby/node_modules/fdir": { + "version": "6.4.4", + "resolved": "https://registry.npmmirror.com/fdir/-/fdir-6.4.4.tgz", + "integrity": "sha512-1NZP+GK4GfuAv3PqKvxQRDMjdSRZjnkq7KfhlNrCNNlZ0ygQFpebfrnfnq/W7fpUnAv9aGWmY1zKx7FYL3gwhg==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/tinyglobby/node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmmirror.com/to-regex-range/-/to-regex-range-5.0.1.tgz", diff --git a/script-hook-website/webpack.config.js b/script-hook-website/webpack.config.js index 4db4b80..efdc2cd 100644 --- a/script-hook-website/webpack.config.js +++ b/script-hook-website/webpack.config.js @@ -1,5 +1,6 @@ const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); +const CopyWebpackPlugin = require('copy-webpack-plugin'); module.exports = (env, argv) => { const isProduction = argv.mode === 'production'; @@ -41,6 +42,15 @@ module.exports = (env, argv) => { 'Expires': {'http-equiv': 'Expires', 'content': '0'} } }), + new CopyWebpackPlugin({ + patterns: [ + { + from: 'public/images', + to: 'images' + }, + // 如果有其他静态资源也需要复制,可以在这里添加 + ] + }), ], devServer: { static: { From 0eb8eb8348058d2b71e848a9e2eb033370224c0f Mon Sep 17 00:00:00 2001 From: CC11001100 Date: Mon, 19 May 2025 02:45:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?build:=20=E6=9B=B4=E6=96=B0package.json?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加copy-webpack-plugin@13.0.0依赖 - 用于构建时复制静态资源文件到dist目录 --- script-hook-website/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/script-hook-website/package.json b/script-hook-website/package.json index e7b2d77..2726cef 100644 --- a/script-hook-website/package.json +++ b/script-hook-website/package.json @@ -39,6 +39,7 @@ }, "devDependencies": { "@types/react-syntax-highlighter": "^15.5.13", + "copy-webpack-plugin": "^13.0.0", "css-loader": "^6.7.3", "gh-pages": "^6.3.0", "html-webpack-plugin": "^5.5.1",