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

Replace CRA with Vite #74

Merged
merged 87 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
39c22cf
replacing CRA boilerplate with Vite incl env vars
AjobK Aug 27, 2024
67d54a3
go back to using es6
AjobK Aug 27, 2024
2ed7a78
newline in gitignore for vite
AjobK Aug 27, 2024
8237878
dynamic env config
AjobK Aug 27, 2024
9fdfeac
newline in config
AjobK Aug 27, 2024
858905b
cleanup from PR, small typing fix
AjobK Aug 27, 2024
15cde30
fixed eslint errors except 'any' type
AjobK Aug 27, 2024
151efa8
install vitest
AjobK Aug 27, 2024
797813d
removes whitespace in eslintrc
AjobK Aug 27, 2024
1e499fe
replace watchall flag fragment in ci
AjobK Aug 27, 2024
21fafdd
replace jest with vitest
AjobK Aug 28, 2024
faa2bc9
edit vitest config, add globals
AjobK Aug 28, 2024
9a233d5
remove all eslint issues (mostly any)
AjobK Aug 28, 2024
0dde152
rename lighthouserc
AjobK Aug 28, 2024
11dad3c
config for lighthouse with esm support
AjobK Aug 29, 2024
3cfc017
remove lighthouse tmp files
AjobK Aug 29, 2024
3e15f64
ignore lighthouse tmp files
AjobK Aug 29, 2024
e37bf35
live attempt for build folder
AjobK Aug 29, 2024
d3f2afe
change standard build dir for vite
AjobK Aug 29, 2024
fbf38bc
change nodejs version
AjobK Aug 29, 2024
b4302ea
changed upload target
AjobK Aug 29, 2024
fd6f505
symlink only
AjobK Aug 29, 2024
73a9234
update comment on symlinks
AjobK Aug 29, 2024
5af791d
Update Dockerfile
tomasr8 Sep 3, 2024
f301092
Add basic vite pwa plugin setup
tomasr8 Sep 3, 2024
787d943
Update workbox-core
tomasr8 Sep 3, 2024
97799d3
Remove unused workbox packages
tomasr8 Sep 3, 2024
8abd85a
Remove web-vitals
tomasr8 Sep 3, 2024
921dc88
Remove old service worker code
tomasr8 Sep 3, 2024
f2249b8
Use the default build folder
tomasr8 Sep 3, 2024
ab1321e
Remove unused favicon
tomasr8 Sep 3, 2024
a2c5c64
Update robots.txt
tomasr8 Sep 3, 2024
b7f4472
Fully configure vite-plugin-pwa
tomasr8 Sep 3, 2024
4d065af
Remove unused dependencies
tomasr8 Sep 3, 2024
4de829c
Use @babel/eslint-parser instead of babel-eslint
tomasr8 Sep 3, 2024
f7ad8a7
Update some eslint plugins
tomasr8 Sep 3, 2024
9dd1714
Fix eslint warnings
tomasr8 Sep 3, 2024
0488043
Remove overrides
tomasr8 Sep 3, 2024
1d177db
Fix TS errors
tomasr8 Sep 3, 2024
05ea91e
Use better types for handleError
tomasr8 Sep 3, 2024
9db4e7f
Add a 'typecheck' script
tomasr8 Sep 3, 2024
526dfdc
Use better typing for QR code data validation
tomasr8 Sep 4, 2024
f9b074a
Use better types for camelizeKeys
tomasr8 Sep 4, 2024
78af8b1
Use better types for deepEqual
tomasr8 Sep 4, 2024
ea7b591
Remove unused test dependencies
tomasr8 Sep 4, 2024
e47167d
Update @testing-library/jest-dom
tomasr8 Sep 4, 2024
fe2d1b2
Remove prop-types
tomasr8 Sep 4, 2024
181d41e
rename service-worker file
AjobK Sep 9, 2024
66886bb
move order of service-worker.js
AjobK Sep 10, 2024
0b6a4b7
build base path update vite
AjobK Sep 11, 2024
28ea648
change prop order viteconf
AjobK Sep 11, 2024
9bf9cb4
workbox config vite
AjobK Sep 11, 2024
aa4b956
add manual skipwaiting msg
AjobK Sep 13, 2024
695001e
Remove immediate registerSW
AjobK Sep 13, 2024
4b503b5
set injectregister to null
AjobK Sep 13, 2024
2097967
Added missing pwa module
AjobK Sep 17, 2024
17ef1bd
additional sw worker fns for testing
AjobK Sep 17, 2024
cf4a501
rollback to old serviceworker
AjobK Sep 17, 2024
64378fc
remove unused packages
AjobK Sep 17, 2024
fcb3bac
add issue comment for SW transition
AjobK Sep 17, 2024
3b958b8
change envdir
AjobK Sep 17, 2024
b120bd2
remove public flag completely
AjobK Sep 17, 2024
a0e0f01
serviceworker log for build
AjobK Sep 17, 2024
432a707
old service-worker implement
AjobK Sep 18, 2024
467c886
use self instead of window in sw
AjobK Sep 18, 2024
ebb618f
remove publicurl snippet
AjobK Sep 18, 2024
7d87384
remove documentation comments
AjobK Sep 18, 2024
f886819
remove unnecessary vitepwa config
AjobK Sep 18, 2024
c7070d1
get rid of unnecessary build files
AjobK Sep 19, 2024
e00a87c
Change config comment vite
AjobK Sep 19, 2024
248c507
remove now redundant png caching line
AjobK Sep 19, 2024
acf4ea2
Use absolute path for sw
AjobK Sep 19, 2024
922a549
extend lint command and fix issues
AjobK Sep 19, 2024
48453a6
rm redundant typing and public path
AjobK Sep 19, 2024
6535338
fix invalid dummy data
AjobK Sep 19, 2024
a5e0cc5
Remove redundant vite conf
AjobK Sep 19, 2024
ef2b13c
cache manifest.json
AjobK Sep 19, 2024
c629c5f
modify access to manifestjson code
AjobK Sep 19, 2024
88a192b
additional cache check and renamed cachename
AjobK Sep 19, 2024
b2e3d00
separate cache for manifest
AjobK Sep 19, 2024
f805479
add json to globpatterns
AjobK Sep 19, 2024
938f838
remove manual manifest caching
AjobK Sep 19, 2024
f0dda90
fix lint issue
AjobK Sep 20, 2024
81af0c3
alternative manifest caching
AjobK Sep 20, 2024
6b5de4f
remove manifest caching (not building)
AjobK Sep 20, 2024
126ae70
Change comment for manifest
AjobK Sep 20, 2024
e8a74a0
mv comment
AjobK Sep 20, 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
8 changes: 3 additions & 5 deletions .env
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# TODO: remove this when we have a better way to handle source maps
GENERATE_SOURCEMAP=false

PORT=3000 # Specify the port to run on

# Custom Variables
REACT_APP_CLIENT_URL=https://localhost:3000
ESLINT_NO_DEV_ERRORS=true
TSC_COMPILE_ON_ERROR=true

REACT_APP_VERSION=${npm_package_version}-dev-${COMMIT_SHA}
VITE_PORT=3000
VITE_VITE_APP_VERSION=${npm_package_version}-dev-${COMMIT_SHA}
VITE_VITE_CLIENT_URL=https://localhost:${VITE_PORT}
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1 +1 @@
REACT_APP_VERSION=${npm_package_version}-${COMMIT_SHA}
VITE_APP_VERSION=${npm_package_version}-${COMMIT_SHA}
35 changes: 32 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
{
"extends": ["plugin:react/recommended", "react-app", "prettier"],
"plugins": ["prettier"],
"extends": [
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"prettier"
],
"plugins": [
"prettier",
"@typescript-eslint",
"import"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"es6": true,
"browser": true,
"node": true
},
"rules": {
"prettier/prettier": "error",
"react/no-unescaped-entities": ["error", {"forbid": [">", "<"]}],
Expand Down Expand Up @@ -28,6 +52,11 @@
}
],
/* Rules to make it not necessary to include React as it is done automatically since React 17 */
"react/react-in-jsx-scope": "off"
"react/react-in-jsx-scope": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{"argsIgnorePattern": "^_", "varsIgnorePattern": "^_", "ignoreRestSiblings": true}
],
"@typescript-eslint/no-empty-function": "off"
}
}
16 changes: 12 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up NodeJS
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
cache: 'npm'

- name: Install dependencies
Expand All @@ -28,22 +28,30 @@ jobs:
- name: Run linters
run: npm run lint

- name: Run type check
run: npm run typecheck

- name: Run tests
run: npm test -- --watchAll=false
run: npm test -- --run

- name: Build the app
run: npm run build

- name: Run Lighthouse CI
id: lhci
# Unfortunately vite requires the index.html to be at the root.
# This means that the public and index.html are separated, which
# affects the building process. Lighthouse also only allows for
# one staticDir. Therefore we need to create a sym link for it.
# https://stackoverflow.com/questions/76590642/how-to-configure-vite-with-index-html-in-public-folder
run: |
npm install -g @lhci/[email protected]
npm install -g @lhci/[email protected]
ln -s $(pwd)/index.html $(pwd)/public/index.html
lhci_output=$(lhci autorun)
echo "$lhci_output"
url=$(echo "$lhci_output" | grep -o "https://.\+")
echo "Found storage url: <$url>"
echo "report_url=$url" >> $GITHUB_OUTPUT

- name: Save data needed by the Lighthouse workflow
if: github.event_name == 'pull_request'
run: |
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/coverage

# production
/build
/dist

# misc
.DS_Store
Expand All @@ -21,3 +21,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

.vite
.lighthouseci
18 changes: 11 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@ FROM node:20-alpine AS builder

RUN apk add --update git

ENV NODE_ENV production
ENV NODE_ENV=production
WORKDIR /app

# Copy the .git folder so we can get the last commit hash
COPY .git .git
COPY package.json package-lock.json ./
COPY tailwind.config.js .
COPY tsconfig.json .
COPY .env.production .
COPY public public
COPY src src
COPY types types
COPY index.html .

COPY package.json package-lock.json .
COPY tailwind.config.js .
COPY tsconfig.json .
COPY .env.production .
COPY vite-env.d.ts vite.config.ts .

RUN npm ci --ignore-scripts
RUN npm ci --ignore-scripts --include=dev
RUN npm run build

FROM nginxinc/nginx-unprivileged:stable-alpine

COPY --from=builder /app/build /html
COPY --from=builder /app/dist /html
COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 8080
Expand Down
20 changes: 4 additions & 16 deletions public/index.html → index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,12 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/logo.png" />
<link rel="icon" href="/logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="theme-color" content="#1D4ED8" />
<meta name="description" content="Indico Check-In App" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% 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
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="/logo.png" />
<link rel="manifest" href="/manifest.json" />

<title>Indico Check-In</title>
</head>
Expand All @@ -37,5 +24,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.tsx"></script>
</body>
</html>
4 changes: 4 additions & 0 deletions lighthouserc.js → lighthouserc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ module.exports = {
upload: {
target: 'temporary-public-storage',
},
collect: {
staticDistDir: './dist',
staticDirFileDiscoveryDepth: 1,
},
},
};
Loading
Loading