Skip to content

Commit a476cef

Browse files
committed
Converted to vite
1 parent 15aac5d commit a476cef

File tree

17 files changed

+1998
-6589
lines changed

17 files changed

+1998
-6589
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/coverage
1010

1111
# production
12-
/build
12+
/dist
1313

1414
# misc
1515
.DS_Store

public/index.html renamed to index.html

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<link rel="icon" sizes="16x16" href="%PUBLIC_URL%/favicon-16x16.png" />
6-
<link rel="icon" sizes="32x32" href="%PUBLIC_URL%/favicon-32x32.png" />
7-
<link rel="icon" sizes="192x192" href="%PUBLIC_URL%/android-chrome-192x192.png" />
8-
<link rel="icon" sizes="512x512" href="%PUBLIC_URL%/android-chrome-512x512.png" />
5+
<link rel="icon" sizes="16x16" href="/favicon-16x16.png" />
6+
<link rel="icon" sizes="32x32" href="/favicon-32x32.png" />
7+
<link rel="icon" sizes="192x192" href="/android-chrome-192x192.png" />
8+
<link rel="icon" sizes="512x512" href="/android-chrome-512x512.png" />
99

1010
<meta name="viewport" content="width=device-width, initial-scale=1" />
1111
<meta name="theme-color" content="#000000" />
1212
<meta name="description" content="View group assignments for a WCA competition" />
1313
<meta property="og:site_name" content="Competition Groups" />
14-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/apple-touch-icon.png" />
14+
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
1515
<script src="https://kit.fontawesome.com/42a36b4555.js" crossorigin="anonymous"></script>
1616
<!--
1717
manifest.json provides metadata used when your web app is installed on a
1818
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
1919
-->
20-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
20+
<link rel="manifest" href="/manifest.json" />
2121
<!--
22-
Notice the use of %PUBLIC_URL% in the tags above.
22+
Notice the use of in the tags above.
2323
It will be replaced with the URL of the `public` folder during the build.
2424
Only files inside the `public` folder can be referenced from the HTML.
2525
26-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
26+
Unlike "/favicon.ico" or "favicon.ico", "/favicon.ico" will
2727
work correctly both with client-side routing and a non-root public URL.
2828
Learn how to configure a non-root public URL by running `npm run build`.
2929
-->
@@ -43,15 +43,7 @@
4343
<body>
4444
<noscript>You need to enable JavaScript to run this app.</noscript>
4545
<div id="root"></div>
46-
<!--
47-
This HTML file is a template.
48-
If you open it directly in the browser, you will see an empty page.
49-
50-
You can add webfonts, meta tags, or analytics to this file.
51-
The build step will place the bundled scripts into the <body> tag.
52-
53-
To begin the development, run `npm start` or `yarn start`.
54-
To create a production bundle, use `npm run build` or `yarn build`.
55-
-->
46+
<!-- Add entry point 👇 -->
47+
<script type="module" src="/src/index.tsx"></script>
5648
</body>
5749
</html>

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
"@types/node": "^18.8.3",
1616
"@types/react": "^18.0.21",
1717
"@types/react-dom": "^18.0.6",
18+
"@types/styled-components": "^5.1.26",
1819
"@typescript-eslint/eslint-plugin": "^5.39.0",
1920
"@typescript-eslint/parser": "^5.39.0",
21+
"@vitejs/plugin-react": "^4.0.3",
2022
"@wca/helpers": "^1.1.1",
2123
"classnames": "^2.3.2",
2224
"clsx": "^1.1.1",
@@ -29,16 +31,20 @@
2931
"react-ga": "^3.3.1",
3032
"react-intersection-observer": "^9.4.2",
3133
"react-router-dom": "^6.2.1",
32-
"react-scripts": "5.0.0",
3334
"react-spinners": "^0.13.8",
3435
"styled-components": "^5.3.5",
3536
"tailwind-styled-components": "^2.1.8",
3637
"typescript": "^4.8.4",
38+
"vite": "^4.4.3",
39+
"vite-plugin-pwa": "^0.16.4",
40+
"vite-plugin-svgr": "^3.2.0",
41+
"vite-tsconfig-paths": "^4.2.0",
3742
"web-vitals": "^1.1.2"
3843
},
3944
"scripts": {
40-
"start": "GENERATE_SOURCEMAP=false react-scripts start",
41-
"build": "react-scripts build",
45+
"start": "vite",
46+
"build": "tsc && vite build",
47+
"serve": "vite preview",
4248
"test": "react-scripts test",
4349
"eject": "react-scripts eject",
4450
"deploy": "NODE_ENV=production npm run build && cp ./build/index.html ./build/200.html && surge ./build/ -d competition-groups.surge.sh"

src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const GlobalStateContext = createContext<{
2929
});
3030

3131
const Navigation = () => {
32-
usePageTracking(process.env.REACT_APP_GA_MEASUREMENT_ID);
32+
usePageTracking(import.meta.env.VITE_GA_MEASUREMENT_ID);
3333

3434
return (
3535
<Routes>

src/components/Grid.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/components/RoomSelector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const Row = styled.div`
1717
const Button = styled.div`
1818
display: flex;
1919
flex: 1;
20-
background-color: ${(props) => (props.highlight ? '#ABB2B9' : 'white')};
20+
background-color: ${(props: { highlight: boolean }) => (props.highlight ? '#ABB2B9' : 'white')};
2121
justify-content: center;
2222
`;
2323

src/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import '@cubing/icons';
33
import reportWebVitals from './reportWebVitals';
44
import App from './App';
55
import './index.css';
6-
import * as serviceWorkerRegistration from './serviceWorkerRegistration';
6+
// import * as serviceWorkerRegistration from './serviceWorkerRegistration';
77
import '@total-typescript/ts-reset';
88

99
const container = document.getElementById('root');
@@ -17,4 +17,4 @@ root.render(<App />);
1717
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
1818
reportWebVitals(undefined);
1919

20-
serviceWorkerRegistration.register();
20+
// serviceWorkerRegistration.register();

src/lib/wca-env.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
export const WCA_ORIGIN =
2-
process.env.REACT_APP_WCA_ORIGIN || 'https://api.worldcubeassociation.org';
1+
export const WCA_ORIGIN = import.meta.env.VITE_WCA_ORIGIN || 'https://api.worldcubeassociation.org';
2+
33
export const WCA_OAUTH_ORIGIN =
4-
process.env.REACT_APP_WCA_OAUTH_ORIGIN || 'https://worldcubeassociation.org';
5-
export const WCA_OAUTH_CLIENT_ID = process.env.REACT_APP_WCA_CLIENT_ID || 'example-application-id';
4+
import.meta.env.VITE_WCA_OAUTH_ORIGIN || 'https://worldcubeassociation.org';
65

7-
// For debug purposes
8-
global.WCA_ORIGIN = WCA_ORIGIN;
9-
global.WCA_OAUTH_CLIENT_ID = WCA_OAUTH_CLIENT_ID;
6+
export const WCA_OAUTH_CLIENT_ID = import.meta.env.VITE_WCA_CLIENT_ID || 'example-application-id';

src/pages/About/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect } from 'react';
22

3-
const Link = ({ to, children }) => (
3+
const Link = ({ to, children }: { to: string; children: React.ReactNode }) => (
44
<a className="text-blue-700 underline" href={to} target="_blank" rel="noreferrer">
55
{children}
66
</a>

src/pages/Competition/Group.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { useParams } from 'react-router-dom';
2+
import { activityCodeToName } from '../../lib/activities';
3+
4+
export default function Group() {
5+
const { eventId, roundNumber } = useParams();
6+
const activityCode = `${eventId}-r${roundNumber}-g:{groupNumber}`;
7+
8+
// Get everyone associated with this activityCode
9+
// Split everyone up by assignmentCode and communicate where they are supposed to be for each group.
10+
11+
return (
12+
<div className="p-2">
13+
<h3 className="text-2xl">Groups for {activityCodeToName(activityCode)}</h3>
14+
</div>
15+
);
16+
}

0 commit comments

Comments
 (0)