Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 28, 2025

This PR fixes the deployment issue where asset URLs in the built application used absolute paths that broke when deployed to GitHub Pages subdirectories.

Problem

The deploy.sh script required manual intervention to change asset URLs from absolute paths to relative paths. When Vite built the application, it generated HTML files with asset references like:

<script type="module" crossorigin src="/assets/index-6295befb.js"></script>

This absolute path /assets/ doesn't work when the application is deployed to a GitHub Pages subdirectory like /pattern-generators/, causing the JavaScript bundle to fail to load.

Solution

Added a Vite configuration file (vite.config.js) that sets the correct base path for GitHub Pages deployment:

import { defineConfig } from 'vite'

export default defineConfig({
  base: '/pattern-generators/'
})

This configuration ensures that asset URLs are generated with the correct path prefix. Now the built HTML contains:

<script type="module" crossorigin src="/pattern-generators/assets/index-6295befb.js"></script>

Changes Made

  1. Created vite.config.js: Configures Vite to use /pattern-generators/ as the base path
  2. Updated deploy.sh: Removed the manual intervention step that prompted users to modify asset URLs

Benefits

  • ✅ Fully automated deployment process - no more manual URL editing required
  • ✅ Consistent asset path handling across development, preview, and production builds
  • ✅ Development server now runs at the correct path: http://localhost:5173/pattern-generators/
  • ✅ Application functionality remains completely intact

Pattern Generator Application

The pattern generator application now works seamlessly with GitHub Pages deployment, generating beautiful line art patterns without any deployment hiccups.

Fixes #1


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…onfig

Co-authored-by: mterczynski <27309340+mterczynski@users.noreply.github.com>
Copilot AI changed the title [WIP] @mterczynski/pattern-generators/issues/1 Fix asset URLs for GitHub Pages deployment by configuring Vite base path Aug 28, 2025
Copilot AI requested a review from mterczynski August 28, 2025 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adjust generated assets url

2 participants