build(web): 配置 Vite 服务端口和代理

- 修改 .env 文件,将 WEB_PORT 改为 VITE_WEB_PORT
- 删除 web/README.md 文件
- 更新 vite.config.js 文件,添加端口和代理配置
This commit is contained in:
2025-04-24 15:52:17 +08:00
parent f620c01faf
commit 786a58c261
3 changed files with 17 additions and 37 deletions

2
.env
View File

@@ -1,2 +1,2 @@
SERVER_PORT = 8080 SERVER_PORT = 8080
WEB_PORT = 80 VITE_WEB_PORT = 80

View File

@@ -1,29 +0,0 @@
# web
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
## Customize configuration
See [Vite Configuration Reference](https://vite.dev/config/).
## Project Setup
```sh
npm install
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Compile and Minify for Production
```sh
npm run build
```

View File

@@ -6,15 +6,24 @@ import vueJsx from '@vitejs/plugin-vue-jsx'
import vueDevTools from 'vite-plugin-vue-devtools' import vueDevTools from 'vite-plugin-vue-devtools'
// https://vite.dev/config/ // https://vite.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [ plugins: [vue(), vueJsx(), vueDevTools()],
vue(),
vueJsx(),
vueDevTools(),
],
resolve: { resolve: {
alias: { alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)) '@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
server: {
// 使用 import.meta.env.VITE_WEB_PORT 来读取 .env 文件中的环境变量
port: 3000,
// 新增正向代理配置
proxy: {
'/api': {
target: 'http://127.0.0.1:8080/api',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
}, },
}, },
}) })