Skip to content
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

Streamline process to deploy to Github Pages #468

Merged
merged 20 commits into from
Aug 17, 2023
Merged

Conversation

ymekuria
Copy link
Collaborator

@ymekuria ymekuria commented Aug 14, 2023

Closes
#467

Problem

Currently to deploy a NextJS UI project that was generated from the zkApp-cli to Github Pages, a user needs to manually configure their project even after running the custom npm run deploy script that is included with the project template. A user needs to update the next.config.js and manually modify their CSS asset urls for them to work properly with GitHub Pages deployment.

Solution

This PR updates the next.config.js file with the necessary configuration and adds a post build script to prepend css asset URLs with the projects repo name so they are correctly deployed to GitHub Pages. The post build script is run along with other GitHub Pages deployment steps when a user enters npm run deploy in a UI project. This script is only added to a project if a user selects the option to deploy to GitHub Pages through the cli.

Tested

This was tested by manually generating UI projects and deploying them to github pages with the npm run deploy script

The ghp-postbuild.js file is added to the src/lib/ui/next directory. This file is necessary for the post-build process in the GitHub Pages deployment workflow.
…end repo-name to asset URLs for compatibility with GitHub Pages deployment

The `ghp-postbuild.js` script is added to modify the built CSS files and prepend the repository name to the asset URLs. This is necessary to ensure compatibility with GitHub Pages deployment. The script reads the CSS files in the `.next/static/css` directory and replaces all occurrences of `url(/)` with `url(/<repoURL>/)`, where `<repoURL>` is the repository name specified in the script. This ensures that the asset URLs are correctly resolved when the app is deployed on GitHub Pages.
…e ghp-postbuild.js

fix(project.js): fix variable assignment in ghpPostInstallScript.replace to correctly set repoURL
… file

The file path for writing the ghp-postbuild.js file has been simplified to `ui/ghp-postbuild.js` instead of `ui/src/pages/ghp-postbuild.js` to improve readability and maintainability.
…nous file operations for better readability and error handling
Add the hero-mina-logo.svg file to the ui library in all frameworks (Next.js, Nuxt.js, and Svelte) to be used as a hero logo in the user interface. This file contains an SVG image of the Mina logo.
…nents instead of string paths for better maintainability and performance
…ages in customNextIndex.js, customNuxtIndex.js, and customPageSvelte.js to match the actual file names and improve consistency and readability
@ymekuria ymekuria merged commit e98a12d into main Aug 17, 2023
20 checks passed
@ymekuria ymekuria deleted the feature/ghp-deploy branch August 17, 2023 07:21
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.

2 participants