46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
import { defineConfig } from 'vite'
|
||
import vue from '@vitejs/plugin-vue'
|
||
import path from 'path'
|
||
import { fileURLToPath } from 'url'
|
||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||
|
||
export default defineConfig({
|
||
plugins: [vue()],
|
||
resolve: {
|
||
alias: {
|
||
'@': path.resolve(__dirname, 'src')
|
||
}
|
||
},
|
||
// 构建配置
|
||
build: {
|
||
outDir: 'dist',
|
||
assetsDir: 'assets',
|
||
// 确保资源路径正确
|
||
assetsInlineLimit: 4096,
|
||
// 生成source map(生产环境可以关闭)
|
||
sourcemap: false
|
||
},
|
||
// 基础路径(如果部署在子目录下需要配置)
|
||
base: '/',
|
||
server: {
|
||
port: 3000,
|
||
proxy: {
|
||
'/api': {
|
||
target: 'http://127.0.0.1:8082',
|
||
changeOrigin: true,
|
||
secure: false,
|
||
ws: true,
|
||
timeout: 30000,
|
||
configure: (proxy, options) => {
|
||
proxy.on('error', (err, req, res) => {
|
||
console.error('代理错误:', err.message)
|
||
console.error('请确保后端服务已启动在 http://127.0.0.1:8082')
|
||
})
|
||
}
|
||
}
|
||
}
|
||
}
|
||
})
|
||
|