小编Vin*_*tti的帖子

使用 create-react-app 进行 Vite 返回 404 错误

我决定配置由 create-react-app 创建的 React 应用程序以开始使用 vite。在遵循一些文档之后,我配置了所需的文件。当我vite在应用程序的根目录中运行时,它会运行,但不幸的是,由于 404 错误,我无法访问这些文件。奇怪的是,对于我的同事来说,它运行。当我更改为react-scripts它时,它运行成功。以下是我的应用程序的一些配置:

\n

vite.config.ts

\n
import { defineConfig } from \'vite\'\nimport react from \'@vitejs/plugin-react\'\nimport path from \'path\'\n\nexport default defineConfig({\n  plugins: [react()],\n  build: {\n    outDir: \'build\',\n  },\n  resolve: {\n    alias: {\n      \'@\': path.resolve(__dirname, \'src\'),\n    },\n  },\n})\n
Run Code Online (Sandbox Code Playgroud)\n

tsconfig.json

\n
{\n  "compilerOptions": {\n    "target": "ESNext",\n    "types": ["vite/client"],\n    "lib": ["dom", "dom.iterable", "esnext"],\n    "allowJs": true,\n    "skipLibCheck": true,\n    "esModuleInterop": true,\n    "allowSyntheticDefaultImports": true,\n    "strict": true,\n    "forceConsistentCasingInFileNames": true,\n    "noFallthroughCasesInSwitch": true,\n    "module": "esnext",\n    "moduleResolution": "node",\n    "resolveJsonModule": true,\n    "isolatedModules": …
Run Code Online (Sandbox Code Playgroud)

reactjs create-react-app vite

2
推荐指数
1
解决办法
8969
查看次数

标签 统计

create-react-app ×1

reactjs ×1

vite ×1