game-deploy

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Game Deployment

游戏部署

Deploy your browser game for public access.
将你的浏览器游戏部署为公开可访问状态。

GitHub Pages Deployment

GitHub Pages部署

Prerequisites

前置条件

  • GitHub CLI installed (
    gh
    )
  • Git repository initialized and pushed to GitHub
  • 已安装GitHub CLI(
    gh
  • Git仓库已初始化并推送到GitHub

Quick Deploy

快速部署

bash
npm run build && npx gh-pages -d dist
bash
npm run build && npx gh-pages -d dist

Full Setup

完整设置

  1. Build the game:
bash
npm run build
  1. Ensure
    vite.config.js
    has the correct base path
    if deploying to a subdirectory:
js
export default defineConfig({
  base: '/<repo-name>/',
  // ... rest of config
});
  1. Deploy with GitHub CLI:
bash
gh repo create <game-name> --public --source=. --push
npm install -D gh-pages
npx gh-pages -d dist
  1. Enable GitHub Pages in repo settings (should auto-detect the
    gh-pages
    branch).
Your game is live at:
https://<username>.github.io/<repo-name>/
  1. 构建游戏:
bash
npm run build
  1. 如果部署到子目录,请确保
    vite.config.js
    配置了正确的基础路径
    :
js
export default defineConfig({
  base: '/<repo-name>/',
  // ... rest of config
});
  1. 使用GitHub CLI部署:
bash
gh repo create <game-name> --public --source=. --push
npm install -D gh-pages
npx gh-pages -d dist
  1. 在仓库设置中启用GitHub Pages(会自动识别
    gh-pages
    分支)。
你的游戏将在以下地址上线:
https://<username>.github.io/<repo-name>/

Automated Deploys

自动化部署

Add to
package.json
:
json
{
  "scripts": {
    "deploy": "npm run build && npx gh-pages -d dist"
  }
}
package.json
中添加以下配置:
json
{
  "scripts": {
    "deploy": "npm run build && npx gh-pages -d dist"
  }
}

Play.fun Registration

Play.fun平台注册

After deploying, register your game on Play.fun for monetization. Use the
/game-creator:playdotfun
skill for integration details.
The deployed URL becomes your
gameUrl
when registering:
typescript
await client.games.register({
  name: 'Your Game Name',
  gameUrl: 'https://<username>.github.io/<repo-name>/',
  maxScorePerSession: 500,
  maxSessionsPerDay: 20,
  maxCumulativePointsPerDay: 5000
});
部署完成后,可在Play.fun平台注册你的游戏以实现变现。如需集成细节,请使用
/game-creator:playdotfun
技能。
部署后的URL将作为你注册时的
gameUrl
参数:
typescript
await client.games.register({
  name: 'Your Game Name',
  gameUrl: 'https://<username>.github.io/<repo-name>/',
  maxScorePerSession: 500,
  maxSessionsPerDay: 20,
  maxCumulativePointsPerDay: 5000
});

Other Hosting Options

其他托管选项

  • Vercel:
    npx vercel --prod
    (auto-detects Vite)
  • Netlify: Connect repo, set build command to
    npm run build
    , publish dir to
    dist
  • Railway: Use the Railway skill for deployment
  • itch.io: Upload the
    dist/
    folder as an HTML5 game
  • Vercel:执行
    npx vercel --prod
    (会自动识别Vite项目)
  • Netlify:关联仓库,设置构建命令为
    npm run build
    ,发布目录为
    dist
  • Railway:使用Railway技能进行部署
  • itch.io:上传
    dist/
    文件夹作为HTML5游戏

Pre-Deploy Checklist

部署前检查清单

  • npm run build
    succeeds with no errors
  • Test the production build with
    npm run preview
  • Remove any
    console.log
    debug statements
  • Verify all assets are included in the build
  • Check mobile/responsive behavior if applicable
  • Set appropriate
    <title>
    and meta tags in
    index.html
  • npm run build
    执行成功且无报错
  • 使用
    npm run preview
    测试生产构建版本
  • 移除所有
    console.log
    调试语句
  • 验证所有资源已包含在构建产物中
  • 若适用,检查移动端/响应式表现
  • index.html
    中设置合适的
    <title>
    和meta标签