This document provides instructions for deploying the Receipt Image Generator app to GitHub Pages and ensuring paths work correctly in both development and production environments.
The app is configured to work in two environments:
- Development: http://localhost:3000/
- Production: https://steven-the-qa.github.io/receipt-image-generator/
-
BrowserRouter with Dynamic Basename:
- In
src/index.js
, the app detects the environment and sets the appropriate basename - This ensures all routes are prefixed with
/receipt-image-generator
in production
- In
-
Asset Path Resolution:
src/utils/pathResolver.js
provides a utility to resolve asset paths correctly- All image paths in the store registry use this resolver
-
404 Page Redirect:
public/404.html
catches all 404 errors and redirects to the main app- The
RedirectHandler
component inApp.js
handles these redirects
-
GitHub Pages Configuration:
package.json
includes the correcthomepage
field
- Ensure all changes are committed to your repository
- Run the deploy command:
npm run deploy
- This will build the app and publish it to the
gh-pages
branch - Your app will be available at https://steven-the-qa.github.io/receipt-image-generator/
If you encounter issues with paths:
-
Image Loading Issues:
- Check browser console for network errors
- Verify image paths in the Network tab
- Ensure images exist in the correct location in
public/images/stores/
-
Routing Issues:
- Check that the RedirectHandler is working properly
- Verify you're using React Router's
Link
component for navigation
-
404 Page Not Working:
- Make sure the 404.html file is in the root of the
build
directory - Check the redirect script in the 404.html file
- Make sure the 404.html file is in the root of the
The path resolver and router configuration automatically handle the difference between development and production, so you should be able to run npm start
and have everything work at http://localhost:3000/
without the /receipt-image-generator
prefix.