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

feat(project): Replace Create React App with Vite #506

Merged
merged 30 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
df52f48
chore(deps): [wip] use vite for dev server
jeremyckahn Dec 13, 2023
392551d
fix(ui): eliminate some visual regressions
jeremyckahn Aug 19, 2024
09bb7bf
fix(project): eliminate Sass warnings
jeremyckahn Aug 20, 2024
6812120
chore(project): [wip] switch from jest to vitest
jeremyckahn Aug 21, 2024
c2b5905
chore(project): [wip] fix some tests
jeremyckahn Aug 22, 2024
2e71ad6
chore(project): [wip] remove top-level importActual
jeremyckahn Aug 22, 2024
4233e02
chore(project): [wip] fix some broken tests
jeremyckahn Aug 22, 2024
76fc41e
chore(project): replace failing Enzyme tests with RTL tests
jeremyckahn Aug 24, 2024
bc16466
chore(project): [wip] fix broken utils tests
jeremyckahn Aug 24, 2024
5ae7afe
fix(project): define vitest global
jeremyckahn Aug 24, 2024
23d67a2
chore(ci): report test coverage
jeremyckahn Aug 24, 2024
618704e
fix(project): load cow template assets as dataUris
jeremyckahn Aug 24, 2024
62ee825
fix(vercel): update ignoreCommand
jeremyckahn Aug 25, 2024
6a275c0
fix(vercel): update framework and outputDirectory
jeremyckahn Aug 25, 2024
de285de
feat(project): use VITE_* environment variables
jeremyckahn Aug 26, 2024
5f89fdf
fix(ui): patch vertical hr style
jeremyckahn Aug 27, 2024
d80ad97
chore(pwa): use vite-plugin-pwa
jeremyckahn Aug 27, 2024
f08f410
fix(ui): remove bad line-height setting
jeremyckahn Aug 28, 2024
11f0579
fix(workflows): use dist directory
jeremyckahn Aug 28, 2024
6c28fc6
fix(tsconfig): update exclude list
jeremyckahn Aug 28, 2024
294092c
chore(deps): remove unused jest packages
jeremyckahn Aug 28, 2024
4102161
chore(scripts): update test:debug and pre-commit hook
jeremyckahn Aug 28, 2024
8187bf8
chore(deps): remove react-scripts
jeremyckahn Aug 28, 2024
d8c1a89
fix(scripts): update build:native configuration
jeremyckahn Aug 29, 2024
71f83b0
chore(build): generate source maps
jeremyckahn Aug 29, 2024
080ef4f
fix(scripts): make print:crops work again
jeremyckahn Aug 29, 2024
eb923c2
fix(config): use --base where PUBLIC_URL was used previously
jeremyckahn Aug 29, 2024
3354455
fix(project): use import.meta.env.MODE instead of import.meta.env.NOD…
jeremyckahn Aug 29, 2024
2b8721e
chore(package): treat package as a module
jeremyckahn Aug 30, 2024
2a5b115
refactor: cleanup
jeremyckahn Aug 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BROWSER=none
REACT_APP_API_ROOT=https://farmhand.vercel.app/
REACT_APP_NAME=$npm_package_name
REACT_APP_VERSION=$npm_package_version
REACT_APP_TURN_USERNAME=
REACT_APP_TURN_CREDENTIAL=
VITE_API_ROOT=https://farmhand.vercel.app/
VITE_NAME=$npm_package_name
VITE_FARMHAND_PACKAGE_VERSION=$npm_package_version
VITE_TURN_USERNAME=
VITE_TURN_CREDENTIAL=
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"globals": {
"vitest": true
},
"extends": ["react-app"],
"rules": {
"import/order": [
Expand Down
11 changes: 2 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,7 @@ jobs:
run: npm ci

- name: 'Run tests'
run: npm test -- --reporters=default --reporters=jest-junit

- name: Test Report
uses: dorny/test-reporter@v1
with:
name: Jest Tests # Name of the check run which will be created
path: reports/jest-*.xml # Path to test results
reporter: jest-junit # Format of test results
run: npm test -- --coverage --run

- name: 'Check types'
# TODO: Change this to check:types when all type errors are fixed
Expand All @@ -44,4 +37,4 @@ jobs:
- uses: actions/upload-artifact@v3
with:
name: build-output
path: build
path: dist
14 changes: 7 additions & 7 deletions .github/workflows/run-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ jobs:
tags: true
branch: main

- run: PUBLIC_URL='./' npm run build
- run: npm run build -- --base="./"
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Prepare Web Artifacts
run: zip farmhand-web-${{ env.PACKAGE_VERSION }}.zip -r build/*
run: zip farmhand-web-${{ env.PACKAGE_VERSION }}.zip -r dist/*

- name: Create Release
id: create_release
Expand All @@ -82,26 +82,26 @@ jobs:
files: |
./farmhand-web-${{ env.PACKAGE_VERSION }}.zip

- run: node -e "console.log(require('./package.json').version)" > build/version.txt
- run: node -e "console.log(require('./package.json').version)" > dist/version.txt
- name: Publish itch.io build
uses: josephbmanley/butler-publish-itchio-action@master
env:
BUTLER_CREDENTIALS: ${{ secrets.ITCH_TOKEN }}
CHANNEL: html5
ITCH_GAME: Farmhand
ITCH_USER: jeremyckahn
PACKAGE: build
VERSION_FILE: build/version.txt
PACKAGE: dist
VERSION_FILE: dist/version.txt

- run: |
PUBLIC_URL='/farmhand' npm run build
npm run build -- --base='/farmhand'

# https://github.com/marketplace/actions/deploy-to-github-pages
- name: Deploy to jeremyckahn.github.io/farmhand
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: build
folder: dist
clean: true
single-commit: true

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ build
Session.vim
.DS_Store
.idea
coverage

.vercel
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Farmhand uses a [SemVer](https://semver.org/)-like versioning system. It differs

## Project overview

- This project is built with [Create React App](https://create-react-app.dev/), so please refer to the documentation of that project to learn about the development toolchain.
- This project uses [Vite](https://vitejs.dev/), so please refer to the documentation of that project to learn about the development toolchain.
- Farmhand uses [Piskel](https://www.piskelapp.com/) for the art assets.

## Running locally
Expand Down Expand Up @@ -138,13 +138,13 @@ The process will take several minutes to complete and it will notify the Discord
Farmhand supports feature flags for code that should only be enabled in specific environments. To create a feature flag, add a line that looks like this in the relevant `.env` file:

```
REACT_APP_ENABLE_[FEATURE_NAME]=true
VITE_ENABLE_[FEATURE_NAME]=true
```

Where `[FEATURE_NAME]` is replaced with the name of your feature. So, adding this to `.env.development.local`:

```
REACT_APP_ENABLE_MINING=true
VITE_ENABLE_MINING=true
```

Would enable the `MINING` feature only for the local development environment. You can access the enabled feature flags at runtime by `import`ing the `features` Object from [`config.js`](https://github.com/jeremyckahn/farmhand/blob/develop/src/config.js). See [Adding Custom Environment Variables](https://create-react-app.dev/docs/adding-custom-environment-variables/) for more information on how to use environment variables.
Expand Down
23 changes: 8 additions & 15 deletions public/index.html → index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,31 @@
<meta name="theme-color" content="#ffe3a1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="shortcut icon" href="/favicon.ico" />
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
Notice the use of in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
Unlike "/favicon.ico" or "favicon.ico", "/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<link
rel="apple-touch-icon"
href="%PUBLIC_URL%/app-icons/ios-appicon-76-76.png"
/>
<link rel="apple-touch-icon" href="/app-icons/ios-appicon-76-76.png" />
<link
rel="apple-touch-icon"
sizes="120x120"
href="%PUBLIC_URL%/app-icons/ios-appicon-120-120.png"
href="/app-icons/ios-appicon-120-120.png"
/>
<link
rel="apple-touch-icon"
sizes="152x152"
href="%PUBLIC_URL%/app-icons/ios-appicon-152-152.png"
href="/app-icons/ios-appicon-152-152.png"
/>
<link
rel="apple-touch-icon"
sizes="180x180"
href="%PUBLIC_URL%/app-icons/ios-appicon-180-180.png"
href="/app-icons/ios-appicon-180-180.png"
/>
<title>Farmhand</title>
<style>
Expand Down Expand Up @@ -99,5 +91,6 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script type="module" src="/src/index.js"></script>
</body>
</html>
34 changes: 34 additions & 0 deletions manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* @type {Partial<import('vite-plugin-pwa').ManifestOptions>}
*/
export const manifest = {
short_name: 'Farmhand',
name: 'Farmhand',
icons: [
{
src: 'favicon.ico',
sizes: '64x64 32x32 24x24 16x16',
type: 'image/x-icon',
},
{
src: 'logo192.png',
type: 'image/png',
sizes: '192x192',
},
{
src: 'logo512.png',
type: 'image/png',
sizes: '512x512',
},
{
src: 'logoMaskable.png',
type: 'image/png',
purpose: 'maskable',
sizes: '731x731',
},
],
start_url: './index.html',
display: 'standalone',
theme_color: '#ffe3a1',
background_color: '#ffffff',
}
Loading
Loading