mirror of
https://github.com/dec0dOS/zero-ui.git
synced 2024-09-20 06:56:05 +08:00
refactor: migrate to vite
This commit is contained in:
parent
5d041f6db6
commit
5c69694505
22
frontend/.eslintrc.json
Normal file
22
frontend/.eslintrc.json
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
"env": { "browser": true, "es2020": true },
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:react/recommended",
|
||||||
|
"plugin:react/jsx-runtime",
|
||||||
|
"plugin:react-hooks/recommended"
|
||||||
|
],
|
||||||
|
"ignorePatterns": ["dist", ".eslintrc.cjs"],
|
||||||
|
"parserOptions": { "ecmaVersion": "latest", "sourceType": "module" },
|
||||||
|
"settings": { "react": { "version": "17.0.2" } },
|
||||||
|
"plugins": ["react-refresh"],
|
||||||
|
"rules": {
|
||||||
|
"react-refresh/only-export-components": [
|
||||||
|
"warn",
|
||||||
|
{ "allowConstantExport": true }
|
||||||
|
],
|
||||||
|
"react/prop-types": ["off"],
|
||||||
|
"no-unused-vars": ["off"]
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,18 +2,18 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<base href="%PUBLIC_URL%/" />
|
<link rel="icon" href="/favicon.ico" />
|
||||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
||||||
<meta
|
<meta
|
||||||
name="viewport"
|
name="viewport"
|
||||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
|
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
|
||||||
/>
|
/>
|
||||||
<meta name="description" content="ZeroUI" />
|
<meta name="description" content="ZeroUI" />
|
||||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
<link rel="manifest" href="/manifest.json" />
|
||||||
<title>ZeroUI</title>
|
<title>ZeroUI</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
<script type="module" src="/src/index.jsx"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -18,23 +18,30 @@
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
"react-is": "^17.0.2",
|
"react-is": "^17.0.2",
|
||||||
"react-router-dom": "^5.2.0",
|
"react-router-dom": "^5.2.0",
|
||||||
"react-scripts": "4.0.3",
|
|
||||||
"react-use": "^17.4.0",
|
"react-use": "^17.4.0",
|
||||||
"styled-components": "^5.3.5"
|
"styled-components": "^5.3.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"source-map-explorer": "^2.5.2"
|
"@types/react": "^18.2.24",
|
||||||
|
"@types/react-dom": "^18.2.9",
|
||||||
|
"@vitejs/plugin-react": "^4.1.0",
|
||||||
|
"eslint": "^8.50.0",
|
||||||
|
"eslint-plugin-react": "^7.33.2",
|
||||||
|
"eslint-plugin-react-hooks": "^4.6.0",
|
||||||
|
"eslint-plugin-react-refresh": "^0.4.3",
|
||||||
|
"rimraf": "^5.0.5",
|
||||||
|
"source-map-explorer": "^2.5.3",
|
||||||
|
"vite": "^4.4.10"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "BROWSER=none react-scripts start",
|
"start": "vite",
|
||||||
"build": "react-scripts build",
|
"build": "vite build",
|
||||||
|
"serve": "vite preview",
|
||||||
|
"clean": "rimraf build",
|
||||||
|
"lint": "eslint src --ext js,jsx --report-unused-disable-directives --max-warnings 0",
|
||||||
"analyze": "source-map-explorer 'build/static/js/*.js'"
|
"analyze": "source-map-explorer 'build/static/js/*.js'"
|
||||||
},
|
},
|
||||||
"homepage": "/app",
|
"homepage": "/app",
|
||||||
"proxy": "http://127.0.0.1:4000",
|
|
||||||
"eslintConfig": {
|
|
||||||
"extends": "react-app"
|
|
||||||
},
|
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
"production": [
|
"production": [
|
||||||
">0.2%",
|
">0.2%",
|
||||||
|
|
|
@ -90,7 +90,7 @@ function Bar() {
|
||||||
>
|
>
|
||||||
{menuItems.map((menuItem, index) => {
|
{menuItems.map((menuItem, index) => {
|
||||||
if (
|
if (
|
||||||
menuItem.hasOwnProperty("condition") &&
|
Object.prototype.hasOwnProperty.call(menuItem, "condition") &&
|
||||||
!menuItem.condition
|
!menuItem.condition
|
||||||
) {
|
) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import LogInToken from "./components/LogInToken";
|
||||||
function LogIn() {
|
function LogIn() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{process.env.NODE_ENV === "development" && (
|
{import.meta.env.DEV && (
|
||||||
<>
|
<>
|
||||||
<LogInToken />
|
<LogInToken />
|
||||||
<Divider orientation="vertical" />
|
<Divider orientation="vertical" />
|
||||||
|
|
|
@ -124,7 +124,7 @@ function NetworkRules({ network, callback }) {
|
||||||
width: "250px",
|
width: "250px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{!!errors.length ? (
|
{errors.length ? (
|
||||||
<Typography color="error">
|
<Typography color="error">
|
||||||
{"[" + errors[0] + ":" + errors[1] + "] " + errors[2]}
|
{"[" + errors[0] + ":" + errors[1] + "] " + errors[2]}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
43
frontend/vite.config.js
Normal file
43
frontend/vite.config.js
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
import { defineConfig } from "vite";
|
||||||
|
import react from "@vitejs/plugin-react";
|
||||||
|
|
||||||
|
// import { join, parse, resolve } from "path";
|
||||||
|
// import * as url from "url";
|
||||||
|
// const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
||||||
|
|
||||||
|
// function entryPoints(...paths) {
|
||||||
|
// const entries = paths.map(parse).map((entry) => {
|
||||||
|
// const { dir, base, name } = entry;
|
||||||
|
// const key = join(dir, name);
|
||||||
|
// const path = resolve(__dirname, dir, base);
|
||||||
|
// return [key, path];
|
||||||
|
// });
|
||||||
|
|
||||||
|
// const config = Object.fromEntries(entries);
|
||||||
|
// return config;
|
||||||
|
// }
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
base: "/app",
|
||||||
|
server: {
|
||||||
|
port: 3000,
|
||||||
|
strictPort: true,
|
||||||
|
proxy: {
|
||||||
|
"/auth": "http://127.0.0.1:4000",
|
||||||
|
"/api": "http://127.0.0.1:4000",
|
||||||
|
"/controller": "http://127.0.0.1:4000",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
components: "/src/components",
|
||||||
|
utils: "/src/utils",
|
||||||
|
external: "/src/external",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
build: {
|
||||||
|
outDir: "build",
|
||||||
|
chunkSizeWarningLimit: 1000,
|
||||||
|
},
|
||||||
|
plugins: [react()],
|
||||||
|
});
|
Loading…
Reference in a new issue