添加新的需求
This commit is contained in:
68
pc-cattle-transportation/vite.config.ts
Normal file
68
pc-cattle-transportation/vite.config.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import * as path from 'path';
|
||||
// eslint-disable-next-line import/no-duplicates
|
||||
import AutoImport from 'unplugin-auto-import/vite';
|
||||
// eslint-disable-next-line import/no-duplicates
|
||||
import autoImport from 'unplugin-auto-import/vite';
|
||||
import Components from 'unplugin-vue-components/vite';
|
||||
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
|
||||
import WindiCSS from 'vite-plugin-windicss';
|
||||
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
// 根据环境设置不同的代理配置
|
||||
const isDev = mode === 'development';
|
||||
|
||||
return {
|
||||
resolve: {
|
||||
// 设置别名
|
||||
alias: {
|
||||
'~': path.resolve(__dirname, './src'),
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
WindiCSS(),
|
||||
vue(),
|
||||
AutoImport({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
}),
|
||||
autoImport({
|
||||
imports: ['vue', 'vue-router', 'pinia'],
|
||||
dts: false,
|
||||
}),
|
||||
Components({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
}),
|
||||
createSvgIconsPlugin({
|
||||
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons/svg')],
|
||||
symbolId: 'icon-[dir]-[name]',
|
||||
}),
|
||||
],
|
||||
define: {
|
||||
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false',
|
||||
},
|
||||
server: isDev ? {
|
||||
port: 8080, // 启动端口
|
||||
open: true,
|
||||
hmr: {
|
||||
// hostManage: '0.0.0.0',
|
||||
host: '127.0.0.1',
|
||||
// hostManage: '192.168.0.49',
|
||||
port: 8080,
|
||||
},
|
||||
// 设置 https 代理
|
||||
proxy: {
|
||||
// 本地开发环境:将前端的 /api 代理到本地后端 Spring Boot 服务
|
||||
// 后端默认端口在 application.yml 中为 16200,context-path 为 /api
|
||||
'/api': {
|
||||
target: 'http://127.0.0.1:16200',
|
||||
changeOrigin: true,
|
||||
},
|
||||
// 如需指向生产环境或测试环境,请按需切换 target:
|
||||
// '/api': { target: 'https://cattletrack.aiotagro.com/', changeOrigin: true },
|
||||
},
|
||||
} : undefined,
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user