Skip to content

Commit 1ec58d8

Browse files
committed
Migrate from react-scripts to vite
To future prove our identifier webapp, this change abandons react-scripts and moves everything to vite as a near seamless transition from the create-react-app based approach when this app was created. Reference: https://vitejs.dev/ Related: reactjs/react.dev#5487
1 parent 870212a commit 1ec58d8

20 files changed

Lines changed: 7558 additions & 15797 deletions

identifier/.env

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
PORT=3001
2-
HOST=127.0.0.1
31
BROWSER=none
4-
ESLINT_NO_DEV_ERRORS=true
5-
REACT_APP_KOPANO_BUILD=0.0.0-dev-env
6-
INLINE_RUNTIME_CHUNK=false
7-
FAST_REFRESH=false
8-
WDS_SOCKET_HOST=0.0.0.0
9-
WDS_SOCKET_PORT=0
2+
VITE_KOPANO_BUILD=0.0.0-dev-env

identifier/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

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

identifier/.yarn/releases/yarn-3.2.2.cjs

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

identifier/.yarn/releases/yarn-4.0.2.cjs

Lines changed: 893 additions & 0 deletions
Large diffs are not rendered by default.

identifier/.yarnrc.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
nodeLinker: node-modules
1+
compressionLevel: mixed
2+
3+
enableGlobalCache: false
24

3-
plugins:
4-
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
5-
spec: "@yarnpkg/plugin-interactive-tools"
5+
nodeLinker: node-modules
66

7-
yarnPath: .yarn/releases/yarn-3.2.2.cjs
7+
yarnPath: .yarn/releases/yarn-4.0.2.cjs

identifier/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ all: build
1616
build: vendor | src i18n ; $(info building identifier Webapp ...) @
1717
@rm -rf build
1818

19-
REACT_APP_KOPANO_BUILD="${VERSION}" CI=false $(YARN) run build
19+
VITE_KOPANO_BUILD="${VERSION}" CI=false $(YARN) run build
2020

2121
.PHONY: src
2222
src:

identifier/README.react.md

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

identifier/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (i *Identifier) writeWebappIndexHTML(rw http.ResponseWriter, req *http.Requ
3535
// FIXME(longsleep): Set a secure CSP. Right now we need `data:` for images
3636
// since it is used. Since `data:` URLs possibly could allow xss, a better
3737
// way should be found for our early loading inline SVG stuff.
38-
rw.Header().Set("Content-Security-Policy", fmt.Sprintf("default-src 'self'; img-src 'self' data:; script-src 'self'; style-src 'self' 'nonce-%s'; base-uri 'none'; frame-ancestors 'none';", nonce))
38+
rw.Header().Set("Content-Security-Policy", fmt.Sprintf("default-src 'self'; img-src 'self' data:; font-src 'self' data:; script-src 'self'; style-src 'self' 'nonce-%s'; base-uri 'none'; frame-ancestors 'none';", nonce))
3939

4040
// Write index with random nonce to response.
4141
index := bytes.Replace(i.webappIndexHTML, []byte("__CSP_NONCE__"), []byte(nonce), 1)
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<!doctype html>
22
<html lang="en">
3-
<head data-kopano-build="%REACT_APP_KOPANO_BUILD%">
3+
<head data-kopano-build="%VITE_KOPANO_BUILD%">
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
66
<meta name="theme-color" content="#ffffff">
7-
<link rel="shortcut icon" href="%PUBLIC_URL%/static/favicon.ico" type="image/x-icon">
7+
<link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon">
88
<meta property="csp-nonce" content="__CSP_NONCE__">
99
<title>Sign in to your account</title>
1010
</head>
@@ -16,5 +16,6 @@
1616
<div></div>
1717
</div>
1818
<div id="root" data-path-prefix="__PATH_PREFIX__"></div>
19+
<script type="module" src="/src/index.tsx"></script>
1920
</body>
2021
</html>

identifier/package.json

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,8 @@
77
"@fontsource/roboto": "^4.5.8",
88
"@material-ui/core": "^4.12.4",
99
"@material-ui/icons": "^4.11.3",
10-
"@testing-library/dom": "^8.20.0",
11-
"@testing-library/jest-dom": "^5.16.5",
12-
"@testing-library/react": "^11.2.7",
13-
"@testing-library/user-event": "^12.8.3",
14-
"@types/jest": "^26.0.24",
15-
"@types/node": "^12.20.55",
16-
"@types/react": "^17.0.59",
17-
"@types/react-dom": "^17.0.20",
18-
"@types/react-redux": "^7.1.25",
19-
"@types/redux-logger": "^3.0.9",
2010
"axios": "^0.22.0",
2111
"classnames": "^2.3.2",
22-
"eslint": "^8.52.0",
2312
"glob": "^8.1.0",
2413
"i18next": "^21.10.0",
2514
"i18next-browser-languagedetector": "^6.1.8",
@@ -32,31 +21,50 @@
3221
"react-redux": "^7.2.9",
3322
"react-router": "^5.3.4",
3423
"react-router-dom": "5.3.4",
35-
"react-scripts": "5.0.1",
3624
"redux": "^4.2.1",
3725
"redux-logger": "^3.0.6",
3826
"redux-thunk": "^2.4.2",
3927
"render-if": "^0.1.1",
40-
"typescript": "^4.9.5",
4128
"web-vitals": "^1.1.2"
4229
},
4330
"scripts": {
44-
"start": "if-node-version '>= 17' && react-scripts --openssl-legacy-provider start || react-scripts start",
45-
"build": "react-scripts build",
46-
"test": "react-scripts test --env=jsdom",
47-
"eject": "react-scripts eject",
48-
"lint": "eslint ./src/**/*.{tsx,ts,jsx,js}",
31+
"start": "vite",
32+
"build": "vite build",
33+
"serve": "vite preview",
34+
"test": "vitest",
35+
"lint": "eslint --max-warnings=0 src/**/*.{ts,tsx,js,jsx}",
4936
"licenses": "NODE_PATH=./node_modules node ../scripts/js-license-ranger.js",
50-
"analyze": "source-map-explorer 'build/static/js/*.js'"
37+
"analyze": "source-map-explorer 'build/static/assets/*.js'"
5138
},
5239
"devDependencies": {
53-
"@typescript-eslint/typescript-estree": "^6.8.0",
40+
"@testing-library/dom": "^8.20.1",
41+
"@testing-library/jest-dom": "^6.1.4",
42+
"@testing-library/react": "^12.1.5",
43+
"@testing-library/user-event": "^12.8.3",
44+
"@types/jest": "^29.5.8",
45+
"@types/node": "^20.9.0",
46+
"@types/react": "^17.0.70",
47+
"@types/react-dom": "^17.0.23",
48+
"@types/react-redux": "^7.1.25",
49+
"@types/redux-logger": "^3.0.12",
50+
"@typescript-eslint/eslint-plugin": "^6.11.0",
51+
"@typescript-eslint/parser": "^6.9.0",
52+
"@typescript-eslint/typescript-estree": "^6.11.0",
53+
"@vitejs/plugin-react": "^4.1.1",
5454
"cldr": "^7.4.0",
55+
"eslint": "^8.53.0",
56+
"eslint-config-react-app-bump": "^1.0.16",
5557
"eslint-plugin-i18next": "^5.2.1",
5658
"i18next-conv": "^12.1.1",
5759
"i18next-parser": "^5.4.0",
5860
"if-node-version": "^1.1.1",
59-
"source-map-explorer": "^1.8.0"
61+
"jsdom": "^22.1.0",
62+
"source-map-explorer": "^1.8.0",
63+
"typescript": "^5.2.2",
64+
"vite": "^4.5.0",
65+
"vite-plugin-checker": "^0.6.2",
66+
"vite-plugin-eslint": "^1.8.1",
67+
"vitest": "^0.34.6"
6068
},
6169
"jest": {
6270
"collectCoverageFrom": [
@@ -68,8 +76,7 @@
6876
"i18next"
6977
],
7078
"extends": [
71-
"react-app",
72-
"react-app/jest",
79+
"react-app-bump",
7380
"plugin:react/recommended",
7481
"plugin:@typescript-eslint/recommended",
7582
"plugin:i18next/recommended"
@@ -106,5 +113,5 @@
106113
"last 1 safari version"
107114
]
108115
},
109-
"packageManager": "yarn@3.2.2"
116+
"packageManager": "yarn@4.0.2"
110117
}

0 commit comments

Comments
 (0)