Skip to content

Commit 4c80db4

Browse files
author
Flatlogic Bot
committed
build: migrate from CRA to Vite and switch env/config pipeline
1 parent d386c1e commit 4c80db4

14 files changed

Lines changed: 123 additions & 247 deletions

File tree

.env

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
NODE_PATH=src/
2-
GENERATE_SOURCEMAP=false
1+
VITE_BACKEND=false

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Looking for a perfect codebase generator for your Startup? Try [Flatlogic AI Web
4444
5. **Enable backend mode (optional)**
4545
- Create `.env.local`:
4646
```bash
47-
REACT_APP_BACKEND=true
47+
VITE_BACKEND=true
4848
```
4949
- Start backend API on `http://localhost:8080`
5050
- Run:
@@ -66,7 +66,7 @@ Looking for a perfect codebase generator for your Startup? Try [Flatlogic AI Web
6666
- MUI `7.x` + Emotion
6767
- React Router `5.x` (Browser History, no hash routing)
6868
- Redux + Context (transitional architecture before consolidation)
69-
- CRA (`react-scripts`) + `react-app-rewired` (Vite migration is planned)
69+
- Vite 5 + `@vitejs/plugin-react`
7070
- Frontend-only users/auth fallback is available when backend is disabled
7171

7272
---
@@ -82,7 +82,7 @@ Looking for a perfect codebase generator for your Startup? Try [Flatlogic AI Web
8282
- Charts Libraries
8383
- Dashboard Pages
8484
- CSS-in-JS Styling
85-
- CRA + react-app-rewired setup
85+
- Vite-based build setup
8686

8787
---
8888

@@ -92,7 +92,7 @@ Looking for a perfect codebase generator for your Startup? Try [Flatlogic AI Web
9292
- MUI 7
9393
- React Hooks & Context API
9494
- React Router v5
95-
- Webpack
95+
- Vite
9696
- Node.js (for backend)
9797

9898
---

config-overrides.js

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

index.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
6+
<meta name="description" content="React Material Admin Full" />
7+
<meta name="theme-color" content="#000000" />
8+
<meta name="referrer" content="no-referrer-when-downgrade" />
9+
<link
10+
rel="stylesheet"
11+
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
12+
/>
13+
<link rel="icon" href="/favicon.png" sizes="16x16" type="image/png" />
14+
<link rel="icon" href="/favicon.png" sizes="32x32" type="image/png" />
15+
<link rel="icon" href="/favicon.png" sizes="48x48" type="image/png" />
16+
<link rel="icon" href="/favicon.png" sizes="62x62" type="image/png" />
17+
<link rel="icon" href="/favicon.png" sizes="80x80" type="image/png" />
18+
<link rel="manifest" href="/manifest.json" />
19+
<title>React Material Admin Full</title>
20+
</head>
21+
<body style="font-family: 'Roboto', sans-serif">
22+
<noscript>You need to enable JavaScript to run this app.</noscript>
23+
<div id="root"></div>
24+
<script type="module" src="/src/index.js"></script>
25+
</body>
26+
</html>

jsconfig.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": "src"
4+
},
5+
"exclude": ["node_modules", "build"]
6+
}

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
"private": true,
66
"homepage": "./",
77
"scripts": {
8-
"build": "cross-env REACT_APP_BACKEND=true NODE_ENV=production PUBLIC_URL='./' react-app-rewired --openssl-legacy-provider build",
9-
"start": "cross-env react-app-rewired --openssl-legacy-provider start",
10-
"dev": "cross-env react-app-rewired --openssl-legacy-provider start",
11-
"test": "react-app-rewired --openssl-legacy-provider test",
8+
"build": "vite build",
9+
"start": "vite",
10+
"dev": "vite",
11+
"preview": "vite preview",
12+
"test": "echo \"Tests are not configured yet\" && exit 0",
1213
"format": "prettier --write src/"
1314
},
1415
"dependencies": {
@@ -48,11 +49,9 @@
4849
"query-string": "7.1.3",
4950
"react": "^19.2.4",
5051
"react-apexcharts": "^2.0.1",
51-
"react-app-rewired": "^2.2.1",
5252
"react-dom": "^19.2.4",
5353
"react-redux": "^9.2.0",
5454
"react-router-dom": "^5.3.4",
55-
"react-scripts": "^5.0.1",
5655
"react-sortablejs": "^1.5.1",
5756
"react-syntax-highlighter": "^11.0.3",
5857
"recharts": "^3.7.0",
@@ -92,8 +91,9 @@
9291
"@types/react": "^19.2.14",
9392
"@types/react-dom": "^19.2.3",
9493
"@types/sortablejs": "^1.15.7",
95-
"cross-env": "^7.0.3",
94+
"@vitejs/plugin-react": "^4.3.3",
9695
"eslint-config-react-app": "^7.0.1",
97-
"sass": "^1.81.0"
96+
"sass": "^1.81.0",
97+
"vite": "^5.4.10"
9898
}
9999
}

public/index.html

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

src/components/Documentation/pages/start/Start.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const Start = () => {
4545
</ListItem>
4646
<ListItem>
4747
<ListItemText
48-
children={<span>3. Enable backend mode by setting <Code inline>REACT_APP_BACKEND=true</Code> in <Code inline>.env.local</Code>, then run <Code inline>npm run dev</Code></span>}
48+
children={<span>3. Enable backend mode by setting <Code inline>VITE_BACKEND=true</Code> in <Code inline>.env.local</Code>, then run <Code inline>npm run dev</Code></span>}
4949
/>
5050
</ListItem>
5151
<ListItem>
@@ -65,7 +65,7 @@ const Start = () => {
6565
</ListItem>
6666
<ListItem>
6767
<ListItemText
68-
children={<span><Code inline>npm test</Code>: run tests in watch mode</span>}
68+
children={<span><Code inline>npm run preview</Code>: preview production build locally</span>}
6969
/>
7070
</ListItem>
7171
<ListItem>

src/components/FormItems/error/errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function selectErrorCode(error) {
2727

2828
export default class Errors {
2929
static handle(error) {
30-
if (process.env.NODE_ENV !== 'test') {
30+
if (import.meta.env.MODE !== 'test') {
3131
console.error(selectErrorMessage(error));
3232
console.error(error);
3333
}

src/config.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
const hostApi = process.env.NODE_ENV === "development"
1+
const isDevelopment = import.meta.env.DEV;
2+
const hostApi = isDevelopment
23
? "http://localhost"
34
: "https://sing-generator-node.herokuapp.com";
4-
const portApi = process.env.NODE_ENV === "development" ? 8080 : "";
5+
const portApi = isDevelopment ? 8080 : "";
56
const baseURLApi = `${hostApi}${portApi ? `:${portApi}` : ``}/api`;
6-
const redirectUrl = process.env.NODE_ENV === "development" ? "http://localhost:3000" : "https://flatlogic.github.io/react-material-admin-full";
7-
const isBackend = String(process.env.REACT_APP_BACKEND).toLowerCase() === "true";
7+
const redirectUrl = isDevelopment
8+
? "http://localhost:3000"
9+
: typeof window !== "undefined"
10+
? window.location.origin
11+
: "https://flatlogic.github.io/react-material-admin-full";
12+
const isBackend = String(import.meta.env.VITE_BACKEND).toLowerCase() === "true";
813

914
const appConfig = {
1015
hostApi,

0 commit comments

Comments
 (0)