Skip to content

Commit 5f13978

Browse files
authored
Update build to use Vite instead of create-react-app (#28)
* use vite maybe idk * use npm * add ~ path * use ~ path * close to working build * getting there * fix process.env * fix emotion stuff * fix things * fix background color * fix buffer usage * dont convert to uint8array * fix build * remove old manifest * remove reference to old manifest * dont define public url default * remove default base url * update github actions * update package-lock.json * fix npm commands * fix eslint things * fix warning about cascading * update github actions * add more aggressive tree shaking * use web-first slippi-js * don't precache all character images * remove backup file * dont try to externalize iconv-lite * fix deps
1 parent e2dade2 commit 5f13978

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+11717
-12408
lines changed

.eslintignore

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

.eslintrc.json

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

.github/workflows/build.yml

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,20 @@ jobs:
1515
runs-on: ${{ matrix.os }}
1616
strategy:
1717
matrix:
18-
node-version: [14.x]
18+
node-version: [20.x]
1919
os: [ubuntu-latest]
2020
steps:
21-
- uses: actions/checkout@v1
21+
- uses: actions/checkout@v4
2222
- name: Use Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
23-
uses: actions/setup-node@v1
23+
uses: actions/setup-node@v4
2424
with:
2525
node-version: ${{ matrix.node-version }}
26-
- name: Cache node modules
27-
uses: actions/cache@v1
28-
id: cache
29-
with:
30-
path: node_modules
31-
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}
32-
restore-keys: |
33-
${{ runner.OS }}-build-${{ env.cache-name }}-
34-
${{ runner.OS }}-build-
35-
${{ runner.OS }}-
26+
cache: "npm"
3627
- name: Install dependencies
37-
if: steps.cache.outputs.cache-hit != 'true'
38-
run: |
39-
yarn install
28+
run: npm install
29+
- name: Run type checking
30+
run: npm run typecheck
31+
- name: Run linting
32+
run: npm run lint
4033
- name: Build
41-
run: |
42-
CI=false yarn run build
34+
run: npm run build

.github/workflows/publish.yml

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,28 @@ jobs:
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
matrix:
17-
node-version: [14.x]
17+
node-version: [20.x]
1818
os: [ubuntu-latest]
1919
steps:
20-
- uses: actions/checkout@v1
20+
- uses: actions/checkout@v4
2121
- name: Use Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
22-
uses: actions/setup-node@v1
22+
uses: actions/setup-node@v4
2323
with:
2424
node-version: ${{ matrix.node-version }}
25-
- name: Cache node modules
26-
uses: actions/cache@v1
27-
id: cache
28-
with:
29-
path: node_modules
30-
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}
31-
restore-keys: |
32-
${{ runner.OS }}-build-${{ env.cache-name }}-
33-
${{ runner.OS }}-build-
34-
${{ runner.OS }}-
25+
cache: "npm"
3526
- name: Install dependencies
36-
if: steps.cache.outputs.cache-hit != 'true'
37-
run: |
38-
yarn install
27+
run: npm install
28+
- name: Run type checking
29+
run: npm run typecheck
30+
- name: Run linting
31+
run: npm run lint
3932
- name: Build and deploy
40-
run: |
41-
CI=false yarn run build
33+
run: npm run build
4234
env:
4335
PUBLIC_URL: /slippi-stats
44-
- name: Publish
45-
uses: peaceiris/actions-gh-pages@v2.4.0
46-
env:
47-
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
48-
PUBLISH_BRANCH: gh-pages
49-
PUBLISH_DIR: ./build
36+
- name: Deploy to GitHub Pages
37+
uses: peaceiris/actions-gh-pages@v4
38+
if: github.ref == 'refs/heads/master'
39+
with:
40+
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
41+
publish_dir: ./dist

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
# production
1212
/build
13+
/dist
1314

1415
# misc
1516
.DS_Store

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Determining who wins a game seems easy at first but once you consider the possib
3535

3636
### How do I show different stats?
3737

38-
First click the *customize stats* button in the top right of the SLP file list to show the list of available stats. Then toggle the checkboxes to enable and disable certain stats from being calculated.
38+
First click the _customize stats_ button in the top right of the SLP file list to show the list of available stats. Then toggle the checkboxes to enable and disable certain stats from being calculated.
3939

4040
![how to customize stats](https://i.imgur.com/6CCWPMr.gif)
4141

@@ -72,21 +72,21 @@ Clone the repo and install dependencies:
7272
```bash
7373
git clone https://github.com/vinceau/slippi-stats
7474
cd slippi-stats
75-
yarn install
75+
npm install
7676
```
7777

7878
In the project directory, you can run:
7979

8080
```bash
81-
yarn run start
81+
npm run start
8282
```
8383

8484
This runs the app in the development mode. Open <http://localhost:3000> to view it in the browser. The page will reload as you make changes.
8585

8686
To build the app for production, run:
8787

8888
```bash
89-
yarn run build
89+
npm run build
9090
```
9191

9292
### Adding Custom Stats

eslint.config.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import js from "@eslint/js";
2+
import globals from "globals";
3+
import reactHooks from "eslint-plugin-react-hooks";
4+
import reactRefresh from "eslint-plugin-react-refresh";
5+
import simpleImportSort from "eslint-plugin-simple-import-sort";
6+
import tseslint from "typescript-eslint";
7+
8+
export default tseslint.config(
9+
{
10+
ignores: ["dist/**", "node_modules/", "**/*.test.{js,jsx,ts,tsx}", "build/**", "stats-old/**"],
11+
},
12+
{
13+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
14+
files: ["**/*.{ts,tsx}"],
15+
languageOptions: {
16+
ecmaVersion: 2020,
17+
globals: {
18+
...globals.browser,
19+
...globals.es2020,
20+
},
21+
parserOptions: {
22+
project: ["./tsconfig.app.json", "./tsconfig.node.json"],
23+
tsconfigRootDir: import.meta.dirname,
24+
},
25+
},
26+
plugins: {
27+
"react-hooks": reactHooks,
28+
"react-refresh": reactRefresh,
29+
"simple-import-sort": simpleImportSort,
30+
},
31+
rules: {
32+
...reactHooks.configs.recommended.rules,
33+
// TypeScript rules
34+
"@typescript-eslint/explicit-function-return-type": "off",
35+
"@typescript-eslint/explicit-member-accessibility": "off",
36+
"@typescript-eslint/no-explicit-any": "off",
37+
"@typescript-eslint/no-unused-vars": "off",
38+
"@typescript-eslint/no-unused-expressions": "warn",
39+
"@typescript-eslint/interface-name-prefix": "off",
40+
41+
// React rules
42+
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
43+
44+
// Import sorting
45+
"simple-import-sort/sort": "warn",
46+
47+
// General rules
48+
"no-console": "off",
49+
"sort-keys": "off",
50+
"sort-imports": "off",
51+
},
52+
},
53+
{
54+
extends: [js.configs.recommended],
55+
files: ["**/*.{js,jsx}"],
56+
languageOptions: {
57+
ecmaVersion: 2020,
58+
globals: {
59+
...globals.browser,
60+
...globals.es2020,
61+
...globals.node,
62+
},
63+
},
64+
rules: {
65+
"no-console": "off",
66+
},
67+
}
68+
);

public/index.html renamed to index.html

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
5+
<link rel="icon" href="/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77
<meta name="theme-color" content="#286163" />
88
<meta name="description" content="Instantly compute Slippi stats and beautifully render the results." />
9-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
10-
<!--
11-
manifest.json provides metadata used when your web app is installed on a
12-
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
13-
-->
14-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
9+
<link rel="apple-touch-icon" href="/logo192.png" />
1510
<!--
1611
Notice the use of %PUBLIC_URL% in the tags above.
1712
It will be replaced with the URL of the `public` folder during the build.
@@ -65,15 +60,6 @@
6560
<body class="themed">
6661
<noscript>You need to enable JavaScript to run this app.</noscript>
6762
<div id="root"></div>
68-
<!--
69-
This HTML file is a template.
70-
If you open it directly in the browser, you will see an empty page.
71-
72-
You can add webfonts, meta tags, or analytics to this file.
73-
The build step will place the bundled scripts into the <body> tag.
74-
75-
To begin the development, run `npm start` or `yarn start`.
76-
To create a production bundle, use `npm run build` or `yarn build`.
77-
-->
63+
<script type="module" src="/src/main.tsx"></script>
7864
</body>
7965
</html>

0 commit comments

Comments
 (0)