Vue 3 + TypeScript + Vite 工程配置,包含 package.json、tsconfig、vite.config.ts 及 .gitignore(忽略 node_modules/dist/自动生成类型声明)。
35 lines
855 B
TypeScript
35 lines
855 B
TypeScript
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
import Components from 'unplugin-vue-components/vite'
|
|
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
|
import path from 'node:path'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue(),
|
|
AutoImport({
|
|
resolvers: [ElementPlusResolver({ importStyle: false })],
|
|
}),
|
|
Components({
|
|
resolvers: [ElementPlusResolver({ importStyle: false })],
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, 'src'),
|
|
},
|
|
},
|
|
server: {
|
|
port: 6801,
|
|
proxy: {
|
|
// 后端服务固定在 7861 端口,前端统一走 /api 相对路径
|
|
'/api': {
|
|
target: 'http://localhost:7861',
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
})
|