Skip to content

Commit d09e4f3

Browse files
committed
Fix preview server to handle Docusaurus baseUrl setting
- Update preview scripts to account for Docusaurus baseUrl '/flywave.gl/' - Add cache disabling flag (-c-1) to ensure latest files are loaded - Update documentation with correct URL path and important notes - The site will now be accessible at http://localhost:3002/flywave.gl/
1 parent ae1c5fd commit d09e4f3

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

docs/PREVIEW_GUIDE.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ npm run preview-build # 启动服务但不自动打开浏览器
1010
npm run preview-build-open # 启动服务并自动打开浏览器
1111
```
1212

13-
服务器将在 http://localhost:3002 上运行。
13+
服务器将在 http://localhost:3002/flywave.gl/ 上运行。
1414

1515
## 方法二:使用脚本文件
1616

@@ -33,17 +33,19 @@ npm install -g http-server
3333

3434
# 在 docs/build 目录启动服务器
3535
cd docs
36-
http-server build -p 3002 -o
36+
http-server build -p 3002 -o -c-1
3737
```
3838

3939
或者使用 npx:
4040
```bash
4141
cd docs
42-
npx http-server build -p 3002 -o
42+
npx http-server build -p 3002 -o -c-1
4343
```
4444

45-
## 注意事项
45+
## 重要注意事项
4646

4747
- 确保先运行 `npm run build``npm run docusaurus-build` 来构建站点
48+
- 由于 Docusaurus 配置中的 baseUrl 为 "/flywave.gl/",网站将在 http://localhost:3002/flywave.gl/ 上提供服务
49+
- 使用 `-c-1` 参数禁用缓存以确保最新的文件被加载
4850
- 服务器默认运行在端口 3002 上,以避免与开发服务器冲突
4951
- 按 Ctrl+C 可以停止服务器

docs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"docusaurus-build": "docusaurus build",
1717
"docusaurus-build-zh": "docusaurus build --locale zh",
1818
"docusaurus-build-en": "docusaurus build --locale en",
19-
"preview-build": "http-server build -p 3002",
20-
"preview-build-open": "http-server build -p 3002 -o",
19+
"preview-build": "http-server build -p 3002 -c-1",
20+
"preview-build-open": "http-server build -p 3002 -o -c-1",
2121
"swizzle": "docusaurus swizzle",
2222
"deploy": "docusaurus deploy",
2323
"clear": "docusaurus clear",

docs/preview-build.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#!/usr/bin/env node
22

33
const { spawn } = require('child_process');
4-
const path = require('path');
54

65
// 启动预览构建后网站的脚本
76
console.log('Starting preview of built documentation site...');
87

9-
// 使用 http-server 预览 build 目录
10-
const server = spawn('npx', ['http-server', 'build', '-p', '3002', '-o'], {
8+
// 使用 http-server 预览 build 目录,设置基础路径为 /flywave.gl/
9+
const server = spawn('npx', ['http-server', 'build', '-p', '3002', '-o', '-c-1'], {
1110
cwd: __dirname, // 设置当前工作目录为脚本所在目录 (docs)
1211
stdio: 'inherit' // 继承父进程的stdio
1312
});
@@ -20,5 +19,5 @@ server.on('close', (code) => {
2019
console.log(`Server process exited with code ${code}`);
2120
});
2221

23-
console.log('Documentation site preview is running at http://localhost:3002');
22+
console.log('Documentation site preview is running at http://localhost:3002/flywave.gl/');
2423
console.log('Press Ctrl+C to stop the server.');

docs/preview-build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ echo "Starting preview of built documentation site..."
66
# 获取脚本所在目录
77
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
88

9-
# 在 docs 目录下启动 http-server 来预览 build 目录
10-
cd "$SCRIPT_DIR" && npx http-server build -p 3002 -o
9+
# 在 docs 目录下启动 http-server 来预览 build 目录,设置基础路径
10+
cd "$SCRIPT_DIR" && npx http-server build -p 3002 -o -c-1
1111

12-
echo "Documentation site preview is running at http://localhost:3002"
12+
echo "Documentation site preview is running at http://localhost:3002/flywave.gl/"
1313
echo "Press Ctrl+C to stop the server."

0 commit comments

Comments
 (0)