fix: move back to react-scripts

This commit is contained in:
ckt1031 2023-07-09 21:18:22 +08:00
parent 28d58849a0
commit 2ae5741214
7 changed files with 1641 additions and 800 deletions

2390
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -10,16 +10,16 @@
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-dropzone": "^14.2.3", "react-dropzone": "^14.2.3",
"react-router-dom": "^6.14.1", "react-router-dom": "^6.14.1",
"react-scripts": "5.0.1",
"react-toastify": "^9.1.3", "react-toastify": "^9.1.3",
"react-turnstile": "^1.1.1", "react-turnstile": "^1.1.1",
"semantic-ui-css": "^2.5.0", "semantic-ui-css": "^2.5.0",
"semantic-ui-react": "^2.1.4" "semantic-ui-react": "^2.1.4"
}, },
"scripts": { "scripts": {
"start": "vite preview --host 0.0.0.0", "start": "react-scripts start",
"build": "vite build", "build": "react-scripts build",
"dev": "vite dev" "test": "react-scripts test",
"eject": "react-scripts eject"
}, },
"eslintConfig": { "eslintConfig": {
"extends": [ "extends": [
@ -40,9 +40,8 @@
] ]
}, },
"devDependencies": { "devDependencies": {
"@vitejs/plugin-react": "^4.0.2",
"prettier": "^2.7.1", "prettier": "^2.7.1",
"vite": "^4.4.2" "react-scripts": "^5.0.1"
}, },
"prettier": { "prettier": {
"singleQuote": true, "singleQuote": true,

View File

@ -14,6 +14,5 @@
<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.js"></script>
</body> </body>
</html> </html>

View File

@ -41,7 +41,7 @@ const Footer = () => {
href='https://github.com/songquanpeng/one-api' href='https://github.com/songquanpeng/one-api'
target='_blank' target='_blank'
> >
{systemName} {import.meta.env.REACT_APP_VERSION}{' '} {systemName} {process.env.REACT_APP_VERSION}{' '}
</a> </a>
{' '} {' '}
<a href='https://github.com/songquanpeng' target='_blank'> <a href='https://github.com/songquanpeng' target='_blank'>

View File

@ -92,7 +92,7 @@ const OtherSetting = () => {
'https://api.github.com/repos/songquanpeng/one-api/releases/latest' 'https://api.github.com/repos/songquanpeng/one-api/releases/latest'
); );
const { tag_name, body } = res.data; const { tag_name, body } = res.data;
if (tag_name === import.meta.env.REACT_APP_VERSION) { if (tag_name === process.env.REACT_APP_VERSION) {
showSuccess(`已是最新版本:${tag_name}`); showSuccess(`已是最新版本:${tag_name}`);
} else { } else {
setUpdateData({ setUpdateData({

View File

@ -2,7 +2,7 @@ import { showError } from './utils';
import axios from 'axios'; import axios from 'axios';
export const API = axios.create({ export const API = axios.create({
baseURL: import.meta.env.REACT_APP_SERVER ? import.meta.env.REACT_APP_SERVER : '', baseURL: process.env.REACT_APP_SERVER ? process.env.REACT_APP_SERVER : '',
}); });
API.interceptors.response.use( API.interceptors.response.use(

View File

@ -1,33 +0,0 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import * as esbuild from "esbuild";
import fs from 'fs/promises';
export default defineConfig(() => ({
plugins: [react()],
build: {
outDir: './build',
},
esbuild: {
loader: "jsx",
include: /src\/.*\.jsx?$/,
// loader: "tsx",
// include: /src\/.*\.[tj]sx?$/,
exclude: [],
},
optimizeDeps: {
esbuildOptions: {
plugins: [
{
name: "load-js-files-as-jsx",
setup(build) {
build.onLoad({ filter: /src\/.*\.js$/ }, async (args) => ({
loader: "jsx",
contents: await fs.readFile(args.path, "utf8"),
}));
},
},
],
},
},
}));