|
@ -1,65 +1,66 @@ |
|
|
import { defineConfig, loadEnv } from 'vite' |
|
|
|
|
|
import react from '@vitejs/plugin-react' |
|
|
|
|
|
import { viteMockServe } from 'vite-plugin-mock' |
|
|
|
|
|
|
|
|
|
|
|
import jotaiDebugLabel from 'jotai/babel/plugin-debug-label' |
|
|
|
|
|
import jotaiReactRefresh from 'jotai/babel/plugin-react-refresh' |
|
|
|
|
|
|
|
|
import { defineConfig, loadEnv } from "vite"; |
|
|
|
|
|
import react from "@vitejs/plugin-react"; |
|
|
|
|
|
import { viteMockServe } from "vite-plugin-mock"; |
|
|
|
|
|
|
|
|
|
|
|
import jotaiDebugLabel from "jotai/babel/plugin-debug-label"; |
|
|
|
|
|
import jotaiReactRefresh from "jotai/babel/plugin-react-refresh"; |
|
|
|
|
|
|
|
|
//import { TanStackRouterVite } from '@tanstack/router-vite-plugin'
|
|
|
//import { TanStackRouterVite } from '@tanstack/router-vite-plugin'
|
|
|
|
|
|
|
|
|
|
|
|
export const downLoadUrl = "http://127.0.0.1:8000"; |
|
|
const proxyMap = { |
|
|
const proxyMap = { |
|
|
'/api/v1/package': 'http://154.88.7.8:45321', |
|
|
|
|
|
'/api/v1/movie': 'http://47.113.117.106:10000', |
|
|
|
|
|
|
|
|
"/api/v1/package": "http://154.88.7.8:45321", |
|
|
|
|
|
"/api/v1/movie": "http://47.113.117.106:10000", |
|
|
//'/api/v1/certold': 'http://192.168.31.41:8000',
|
|
|
//'/api/v1/certold': 'http://192.168.31.41:8000',
|
|
|
'/api/v1/cert': 'http://127.0.0.1:8000', |
|
|
|
|
|
|
|
|
"/api/v1/cert": "http://127.0.0.1:8000", |
|
|
//'/api/v1/cert': 'http://192.168.31.41:8000',
|
|
|
//'/api/v1/cert': 'http://192.168.31.41:8000',
|
|
|
} as Record<any, string> |
|
|
|
|
|
|
|
|
} as Record<any, string>; |
|
|
|
|
|
|
|
|
const proxyConfig = Object.keys(proxyMap).reduce((acc, key) => { |
|
|
|
|
|
acc[key] = { |
|
|
|
|
|
target: proxyMap[key], |
|
|
|
|
|
changeOrigin: true, |
|
|
|
|
|
rewrite: (path: string) => path, |
|
|
|
|
|
} |
|
|
|
|
|
return acc |
|
|
|
|
|
}, {} as Record<any, any>) |
|
|
|
|
|
|
|
|
const proxyConfig = Object.keys(proxyMap).reduce( |
|
|
|
|
|
(acc, key) => { |
|
|
|
|
|
acc[key] = { |
|
|
|
|
|
target: proxyMap[key], |
|
|
|
|
|
changeOrigin: true, |
|
|
|
|
|
rewrite: (path: string) => path, |
|
|
|
|
|
}; |
|
|
|
|
|
return acc; |
|
|
|
|
|
}, |
|
|
|
|
|
{} as Record<any, any>, |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
|
// https://vitejs.dev/config/
|
|
|
export default defineConfig(({ mode }) => { |
|
|
export default defineConfig(({ mode }) => { |
|
|
|
|
|
|
|
|
// 根据当前工作目录中的 `mode` 加载 .env 文件
|
|
|
// 根据当前工作目录中的 `mode` 加载 .env 文件
|
|
|
// 设置第三个参数为 '' 来加载所有环境变量,而不管是否有 `VITE_` 前缀。
|
|
|
// 设置第三个参数为 '' 来加载所有环境变量,而不管是否有 `VITE_` 前缀。
|
|
|
// @ts-ignore fix process
|
|
|
// @ts-ignore fix process
|
|
|
const env = loadEnv(mode, process.cwd(), '') |
|
|
|
|
|
|
|
|
const env = loadEnv(mode, process.cwd(), ""); |
|
|
// 你可以在这里打印出 env 变量来检查加载的内容
|
|
|
// 你可以在这里打印出 env 变量来检查加载的内容
|
|
|
return { |
|
|
return { |
|
|
//定义别名的路径
|
|
|
//定义别名的路径
|
|
|
resolve: { |
|
|
resolve: { |
|
|
alias: { |
|
|
alias: { |
|
|
'@': '/src', |
|
|
|
|
|
|
|
|
"@": "/src", |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
server: { |
|
|
server: { |
|
|
cors: { |
|
|
cors: { |
|
|
origin: '*' |
|
|
|
|
|
|
|
|
origin: "*", |
|
|
}, |
|
|
}, |
|
|
proxy: { |
|
|
proxy: { |
|
|
...proxyConfig, |
|
|
...proxyConfig, |
|
|
'/api': { |
|
|
|
|
|
|
|
|
"/api": { |
|
|
target: env.API_URL, |
|
|
target: env.API_URL, |
|
|
changeOrigin: true, |
|
|
changeOrigin: true, |
|
|
rewrite: (path) => { |
|
|
rewrite: (path) => { |
|
|
return path |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return path; |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
plugins: [ |
|
|
plugins: [ |
|
|
react({ |
|
|
react({ |
|
|
babel: { |
|
|
babel: { |
|
|
presets: [ 'jotai/babel/preset' ], |
|
|
|
|
|
plugins: [ jotaiDebugLabel, jotaiReactRefresh ] |
|
|
|
|
|
|
|
|
presets: ["jotai/babel/preset"], |
|
|
|
|
|
plugins: [jotaiDebugLabel, jotaiReactRefresh], |
|
|
}, |
|
|
}, |
|
|
}), |
|
|
}), |
|
|
viteMockServe({ |
|
|
viteMockServe({ |
|
@ -67,10 +68,10 @@ export default defineConfig(({ mode }) => { |
|
|
enable: false, |
|
|
enable: false, |
|
|
|
|
|
|
|
|
// mock 文件的根路径,默认值:'mocks'
|
|
|
// mock 文件的根路径,默认值:'mocks'
|
|
|
mockPath: 'mock', |
|
|
|
|
|
|
|
|
mockPath: "mock", |
|
|
logger: true, |
|
|
logger: true, |
|
|
}), |
|
|
}), |
|
|
//TanStackRouterVite(),
|
|
|
//TanStackRouterVite(),
|
|
|
], |
|
|
], |
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
}); |