Skip to content

Commit 4be79ca

Browse files
committed
fix: 添加CopyWebpackPlugin解决静态资源部署问题
- 添加copy-webpack-plugin依赖 - 配置webpack复制public/images到dist/images目录 - 解决GitHub Pages部署中图片404问题
1 parent f06bbca commit 4be79ca

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed

script-hook-website/package-lock.json

Lines changed: 83 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

script-hook-website/webpack.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const path = require('path');
22
const HtmlWebpackPlugin = require('html-webpack-plugin');
3+
const CopyWebpackPlugin = require('copy-webpack-plugin');
34

45
module.exports = (env, argv) => {
56
const isProduction = argv.mode === 'production';
@@ -41,6 +42,15 @@ module.exports = (env, argv) => {
4142
'Expires': {'http-equiv': 'Expires', 'content': '0'}
4243
}
4344
}),
45+
new CopyWebpackPlugin({
46+
patterns: [
47+
{
48+
from: 'public/images',
49+
to: 'images'
50+
},
51+
// 如果有其他静态资源也需要复制,可以在这里添加
52+
]
53+
}),
4454
],
4555
devServer: {
4656
static: {

0 commit comments

Comments
 (0)