forked from scratchfoundation/scratch-gui
-
-
Notifications
You must be signed in to change notification settings - Fork 16
fix: resolve GitHub Pages subdirectory deployment publicPath issues #408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Configure webpack publicPath to use PUBLIC_PATH environment variable - Add rebuild steps in CI/CD for different deployment targets: - smalruby.app: uses existing build with PUBLIC_PATH="/" - smalruby3-gui: rebuilds with PUBLIC_PATH="/smalruby3-gui/" - branch deployments: rebuilds with PUBLIC_PATH="/smalruby3-gui/<branch>/" - Fix sprite/background selection functionality on GitHub Pages subdirectory - Maintain efficient build process by reusing test build for smalruby.app Fixes asset loading issues where chunks were expected at root path but deployed to subdirectories. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Address lint error (comma-dangle) in distConfig configuration. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…st compatibility - Set publicPath default to 'auto' instead of '/' to generate relative paths - Fixes integration test failures where file:// protocol requires relative paths - Maintains compatibility with environment variable override for deployment Integration test now passes after this change: ✓ Ruby Tab: Mesh extension blocks › Ruby -> Code -> Ruby 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Replace hardcoded publicPath: './' with process.env.PUBLIC_PATH || 'auto' - Ensures consistent path handling across all webpack plugins - Allows PWA manifest to use correct base path for different deployments Test confirmed: PUBLIC_PATH="/smalruby3-gui/" now correctly generates <script defer src="/smalruby3-gui/gui.js"></script> in index.html 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…ementPlugin - Add NormalModuleReplacementPlugin to override worker-loader options - Ensure PUBLIC_PATH environment variable is passed to worker chunks - This is part of comprehensive fix for GitHub Pages subdirectory deployment Related to fetch-worker.js path resolution issue where workers were requesting relative paths instead of respecting publicPath setting. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Add sed command to fix worker-loader chunk paths after build - Replace relative 'chunks/' paths with absolute '/smalruby3-gui/chunks/' paths - Apply fix for both smalruby3-gui and branch deployments - This addresses worker-loader not respecting webpack publicPath setting The fix ensures fetch-worker.js is requested from correct absolute path instead of relative path on GitHub Pages subdirectory deployments. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Remove unnecessary escape characters in regex patterns - Fix arrow function formatting by removing unnecessary parentheses - Maintain functionality while adhering to ESLint rules 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Add scripts/postbuild.mjs to automatically fix fetch-worker paths when PUBLIC_PATH is set - Integrate post-build script into npm build process in package.json - Remove manual sed commands from CI/CD workflow (.github/workflows/ci-cd.yml) - Update CLAUDE.md documentation to reflect automated process (no more gsed required) - Simplify local testing workflow - just set PUBLIC_PATH and run npm build - Improve cross-platform compatibility by removing bash sed dependency This resolves GitHub Pages subdirectory deployment issues for worker loading while maintaining a clean, automated build process. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Improved postbuild.mjs script with additional regex pattern for arrow functions - Fixed webpack externals configuration syntax - Resolved import path issues in ruby-to-blocks-converter - Enhanced pattern detection for worker-loader generated code This completes the GitHub Pages publicPath fix to ensure sprite/background selection functionality works correctly on subdirectory deployments. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Add explicit .nojekyll file creation before each GitHub Pages deployment - Fix "no such file or directory: build/.*" error in peaceiris/actions-gh-pages - Ensure Jekyll is properly disabled for all deployments - Add CNAME creation for smalruby.app deployment This resolves the CI error where the deployment action was trying to copy hidden files that didn't exist in the build directory. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
github-actions bot
pushed a commit
that referenced
this pull request
Sep 15, 2025
…ges-public-path fix: resolve GitHub Pages subdirectory deployment publicPath issues
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Problem
GitHub Pages subdirectory deployment (
https://smalruby.jp/smalruby3-gui/
) was failing to load worker files because:"chunks/" + "fetch-worker"
/chunks/fetch-worker.js
instead of/smalruby3-gui/chunks/fetch-worker.js
Solution
Automated Post-Build Processing
scripts/postbuild.mjs
automatically detectsPUBLIC_PATH
environment variablePUBLIC_PATH
is set (no changes for default builds)return "chunks/" + "fetch-worker"
with absolute pathspackage.json
build script:webpack && node ./scripts/postbuild.mjs
CI/CD Workflow Simplification
sed
commands from all deployment stepsnpm run build
with appropriatePUBLIC_PATH
Key Files Changed
scripts/postbuild.mjs
- New automated post-build processorpackage.json
- Integrated post-build script into build process.github/workflows/ci-cd.yml
- Removed manual sed commandsCLAUDE.md
- Updated local testing documentation (no more gsed required)Technical Implementation
The post-build script:
PUBLIC_PATH
environment variable is setbuild/gui.js
andbuild/player.js
PUBLIC_PATH
Example transformation:
Test Plan
PUBLIC_PATH
- no changes appliedPUBLIC_PATH="/smalruby3-gui/"
- paths correctly fixedBenefits
Breaking Changes
None. This is a bug fix that maintains backward compatibility while simplifying the development workflow.
🤖 Generated with Claude Code