You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
haoliang-net/frontend/vite.config.ts

46 lines
1.1 KiB
TypeScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { viteMockPlugin } from './mock/plugin'
import path from 'path'
// https://vite.dev/config/
export default defineConfig(({ command }) => ({
// build时部署到/admin/子路径dev时用根路径
base: command === 'build' ? '/admin/' : '/',
plugins: [
vue(),
viteMockPlugin({
mockPath: 'mock',
enable: true,
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
server: {
port: 5173,
// 将/api请求代理到IIS后端真实数据
proxy: {
'/api': {
target: 'http://127.0.0.1',
changeOrigin: true,
},
},
},
// 构建优化配置
build: {
// 输出到 CncWebApi/admin 目录IIS 直接服务
outDir: path.resolve(__dirname, '../src/CncWebApi/admin'),
// 不清空目标目录(避免删除其他文件)
emptyOutDir: true,
rollupOptions: {
output: {
// Vite 8 (Rolldown) 使用 codeSplitting 替代 manualChunks
codeSplitting: true,
}
}
},
}))