refactor(web): migrate create-react-app to vite (#787)

* removed react-app type instead use vite.

* removed index.html from public since vite uses it from root: read more: https://vitejs.dev/guide/#index-html-and-project-root

* yarn.lock update.

* added vite config file. With commented rollUp option if we want the build to be called build but using default stuff for now.

* updated tsconfig to use vite and include vite.config.ts

* changed package json build commands to use vite.

* for some reason there is an error in vite config when we put project as tsconfig.json.

* build.go updated to use the new dist folder.

* refactored as well updated to use dist and web.AssetHandler again.

* Fixed issue forcing the frontend to be reloaded for all routes to work if logged in fresh without reloading it will always go back to dashboard.

* updated it to use the new function; need to fix the Index for baseUrl I believe, if enabled it works except logs route will crash due to cors.

* refactored and default port to 7474, don't think we need the rollUpOptions.

* added tmp/ to ignore .

* init air.toml, for dev hot reloading both app and backend. https://github.com/cosmtrek/air run it using air but make sure it's in PATH

* updated the start command to build and watch for changes, works great with air.

* revert

* added proxy for vite config. To be used for dev.

* refactor: I think this should fix it, when logs route etc getting accessed usually it throws error but by getting rid of the catch-all it should work as intended, since web.RegisterHandler(r) will catch the unmatched ones.

* fix: baseurl and build

* fix(build): docker ignore !web/dist

* fix(build): dockerignore add exclusions

* docs: update README.md

* build: update postcss config

---------

Co-authored-by: KaiserBh <kaiserbh@proton.me>
Co-authored-by: ze0s <ze0s@riseup.net>
This commit is contained in:
KaiserBh 2023-04-08 00:04:10 +10:00 committed by GitHub
parent 2fa75d85d5
commit edae1bbf4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 715 additions and 9457 deletions

View file

@ -24,16 +24,15 @@
"react-query": "^3.39.1",
"react-ridge-state": "4.2.2",
"react-router-dom": "^6.3.0",
"react-scripts": "^5.0.1",
"react-select": "^5.3.2",
"react-table": "^7.8.0",
"react-tooltip": "^5.5.2",
"stacktracey": "^2.1.8"
},
"scripts": {
"start": "BROWSER=none react-scripts start",
"build": "react-scripts build",
"eject": "react-scripts eject",
"start": "vite",
"build": "tsc && vite build",
"serve": "vite preview",
"lint": "eslint src/ --ext .js,.jsx,.ts,.tsx --color",
"lint:watch": "npm run lint -- --watch"
},
@ -58,6 +57,7 @@
"@types/react-table": "^7.7.12",
"@typescript-eslint/eslint-plugin": "^5.28.0",
"@typescript-eslint/parser": "^5.28.0",
"@vitejs/plugin-react-swc": "^3.2.0",
"autoprefixer": "^10.4.7",
"eslint": "^8.17.0",
"eslint-plugin-import": "^2.26.0",
@ -67,7 +67,8 @@
"http-proxy-middleware": "^2.0.6",
"postcss": "^8.4.14",
"tailwindcss": "^3.1.3",
"typescript": "^4.7.3"
"typescript": "^4.7.3",
"vite": "^4.2.1"
},
"packageManager": "yarn@3.2.2"
}