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

Feature/transition to vite #364

Merged
merged 18 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
5ddd95c
Add vite and initial configuration changes to support it
courtneymyers Oct 3, 2023
94da3b1
Update REACT_APP prefixed env variables to be VITE prefixed
courtneymyers Oct 3, 2023
5554ee7
Remove no longer used react app type declaration file, reportWebVital…
courtneymyers Oct 3, 2023
50fb5ca
Update all files to use new @ alias import paths
courtneymyers Oct 3, 2023
056b6c7
Update proxy setup (to server app) to work with vite
courtneymyers Oct 4, 2023
7e856b6
Add login and logout routes to vite proxy config and remove need for …
courtneymyers Oct 4, 2023
472b26c
Configure Tailwind CSS for Vite
courtneymyers Oct 4, 2023
44a4472
Update tailwind preflight stylesheet to use :where() pseudo-class fun…
courtneymyers Oct 4, 2023
43e3745
Uninstall react-scripts, and update README for Vite
courtneymyers Oct 4, 2023
a939a7a
Remove no longer needed CRA-related packages
courtneymyers Oct 4, 2023
b3dd749
Update TypeScript
courtneymyers Oct 4, 2023
75fcc11
Move (and upgrade) @types packages to devDependencies, and remove no …
courtneymyers Oct 4, 2023
9f8d66d
Add eslint
courtneymyers Oct 4, 2023
0386de6
Update arguments to be prefixed with an underscore if they're unused …
courtneymyers Oct 4, 2023
e657601
Update GitHub workflows to use VITE_ env prefix instead of REACT_APP_
courtneymyers Oct 4, 2023
5258f39
Move @tailwindcss/forms to devDependencies
courtneymyers Oct 4, 2023
995d046
Update text on 404 page
courtneymyers Oct 4, 2023
01e51fa
Update vite build config to output files similar to create react app'…
courtneymyers Oct 4, 2023
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
8 changes: 4 additions & 4 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ jobs:
- name: Build front-end files and move to server
run: |
PUBLIC_URL="$SERVER_URL" \
REACT_APP_SERVER_BASE_PATH="$SERVER_BASE_PATH" \
REACT_APP_CLOUD_SPACE="$CLOUD_SPACE" \
REACT_APP_FORMIO_BASE_URL="$FORMIO_BASE_URL" \
REACT_APP_FORMIO_PROJECT_NAME="$FORMIO_PROJECT_NAME" \
VITE_SERVER_BASE_PATH="$SERVER_BASE_PATH" \
VITE_CLOUD_SPACE="$CLOUD_SPACE" \
VITE_FORMIO_BASE_URL="$FORMIO_BASE_URL" \
VITE_FORMIO_PROJECT_NAME="$FORMIO_PROJECT_NAME" \
npm run build
rm ../server/app/public/index.html
cd build
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ jobs:
- name: Build front-end files and move to server
run: |
PUBLIC_URL="$SERVER_URL" \
REACT_APP_SERVER_BASE_PATH="$SERVER_BASE_PATH" \
REACT_APP_CLOUD_SPACE="$CLOUD_SPACE" \
REACT_APP_FORMIO_BASE_URL="$FORMIO_BASE_URL" \
REACT_APP_FORMIO_PROJECT_NAME="$FORMIO_PROJECT_NAME" \
VITE_SERVER_BASE_PATH="$SERVER_BASE_PATH" \
VITE_CLOUD_SPACE="$CLOUD_SPACE" \
VITE_FORMIO_BASE_URL="$FORMIO_BASE_URL" \
VITE_FORMIO_PROJECT_NAME="$FORMIO_PROJECT_NAME" \
npm run build
rm ../server/app/public/index.html
cd build
Expand Down
8 changes: 4 additions & 4 deletions app/client/.env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NOTE: For local development, set `REACT_APP_FORMIO_BASE_URL` and
# `REACT_APP_FORMIO_PROJECT_NAME` to the same values used in the server app's
# NOTE: For local development, set `VITE_FORMIO_BASE_URL` and
# `VITE_FORMIO_PROJECT_NAME` to the same values used in the server app's
# `FORMIO_BASE_URL` and `FORMIO_PROJECT_NAME` env variables. When deployed, a
# GitHub Actions Workflow does this in the "build" npm script.
REACT_APP_FORMIO_BASE_URL=
REACT_APP_FORMIO_PROJECT_NAME=
VITE_FORMIO_BASE_URL=
VITE_FORMIO_PROJECT_NAME=
21 changes: 21 additions & 0 deletions app/client/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
root: true,
env: {
browser: true,
es2020: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
};
57 changes: 19 additions & 38 deletions app/client/README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,27 @@
# Getting Started with Create React App
# React + TypeScript + Vite

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

## Available Scripts
Currently, two official plugins are available:

In the project directory, you can run:
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

### `npm start`
## Expanding the ESLint configuration

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

The page will reload if you make edits.\
You will also see any lint errors in the console.
- Configure the top-level `parserOptions` property like this:

### `npm test`
```js
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
```

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
50 changes: 16 additions & 34 deletions app/client/public/index.html → app/client/index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
name="description"
content="U.S. EPA CSB Rebate Forms Application"
/>
<meta name="description" content="U.S. EPA CSB Rebate Forms Application" />
<meta property="DC.creator" content="US EPA" />
<meta
property="DC.description"
Expand All @@ -20,18 +17,12 @@
property="DC.Subject.epachannel"
content="Learn the Issues, Science &amp; Technology"
/>
<meta
property="DC.title"
content="CSB Rebate Forms Application"
/>
<meta property="DC.title" content="CSB Rebate Forms Application" />
<meta property="DC.type" content="Data and Tools" />
<meta property="og:site_name" content="US EPA" />
<meta property="og:type" content="website" />
<meta property="og:url" content="%PUBLIC_URL%/" />
<meta
property="og:title"
content="CSB Rebate Forms Application | US EPA"
/>
<meta property="og:url" content="/" />
<meta property="og:title" content="CSB Rebate Forms Application | US EPA" />
<meta
property="og:description"
content="U.S. EPA CSB Rebate Forms Application"
Expand All @@ -49,13 +40,13 @@
name="twitter:title"
content="CSB Rebate Forms Application | US EPA"
/>
<meta name="twitter:url" content="%PUBLIC_URL%/" />
<meta name="twitter:url" content="/" />
<meta name="twitter:image:height" content="600" />
<meta name="twitter:image:width" content="1200" />
<meta name="msapplication-TileColor" content="#005ea2" />
<meta name="theme-color" content="#005ea2" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link rel="canonical" href="%PUBLIC_URL%/" />
<link rel="manifest" href="/manifest.json" />
<link rel="canonical" href="/" />
<link
rel="apple-touch-icon-precomposed"
sizes="196x196"
Expand Down Expand Up @@ -331,7 +322,7 @@
<button class="usa-nav__close" aria-label="Close">
<svg class="icon icon--nav-close" aria-hidden="true" role="img">
<title>Primary navigation</title>
<use href="%PUBLIC_URL%/img/sprite.artifact.svg#close" />
<use href="/img/sprite.artifact.svg#close" />
</svg>
</button>

Expand Down Expand Up @@ -395,6 +386,7 @@
<article class="article">
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</article>
</div>

Expand Down Expand Up @@ -640,9 +632,7 @@ <h2>Follow.</h2>
href="https://www.facebook.com/EPA"
>
<svg class="icon icon--social" aria-hidden="true">
<use
href="%PUBLIC_URL%/img/sprite.artifact.svg#facebook-square"
/>
<use href="/img/sprite.artifact.svg#facebook-square" />
</svg>
</a>
</li>
Expand All @@ -653,9 +643,7 @@ <h2>Follow.</h2>
href="https://twitter.com/epa"
>
<svg class="icon icon--social" aria-hidden="true">
<use
href="%PUBLIC_URL%/img/sprite.artifact.svg#twitter-square"
/>
<use href="/img/sprite.artifact.svg#twitter-square" />
</svg>
</a>
</li>
Expand All @@ -666,9 +654,7 @@ <h2>Follow.</h2>
href="https://www.youtube.com/user/USEPAgov"
>
<svg class="icon icon--social" aria-hidden="true">
<use
href="%PUBLIC_URL%/img/sprite.artifact.svg#youtube-square"
/>
<use href="/img/sprite.artifact.svg#youtube-square" />
</svg>
</a>
</li>
Expand All @@ -679,9 +665,7 @@ <h2>Follow.</h2>
href="https://www.flickr.com/photos/usepagov"
>
<svg class="icon icon--social" aria-hidden="true">
<use
href="%PUBLIC_URL%/img/sprite.artifact.svg#flickr-square"
/>
<use href="/img/sprite.artifact.svg#flickr-square" />
</svg>
</a>
</li>
Expand All @@ -692,9 +676,7 @@ <h2>Follow.</h2>
href="https://www.instagram.com/epagov"
>
<svg class="icon icon--social" aria-hidden="true">
<use
href="%PUBLIC_URL%/img/sprite.artifact.svg#instagram-square"
/>
<use href="/img/sprite.artifact.svg#instagram-square" />
</svg>
</a>
</li>
Expand All @@ -706,7 +688,7 @@ <h2>Follow.</h2>

<a href="#top" class="back-to-top" title="Back to top">
<svg class="back-to-top__icon" role="img" aria-label="Back to top">
<use href="%PUBLIC_URL%/img/sprite.artifact.svg#arrow" />
<use href="/img/sprite.artifact.svg#arrow" />
</svg>
</a>

Expand Down
Loading
Loading