| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import { defineConfig, loadEnv } from 'vite'
- import createVitePlugins from './vite/plugins'
- import path from 'path'
- export default defineConfig(({ mode, command }) => {
- const env = loadEnv(mode, process.cwd())
- const { VITE_APP_ENV, VITE_BASE_PATH } = env
-
- return {
- plugins: createVitePlugins(env, command === 'build'),
- // 部署生产环境和开发环境下的URL。
- // 默认情况下,vite 会假设你的应用是被部署在一个域名的根路径上
- // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
- base: VITE_BASE_PATH,
- server: {
- port: 3001,
- host: true,
- open: true,
- proxy: {
- // https://cn.vitejs.dev/config/#server-proxy
- '/dev-api': {
- // target: 'https://api.hninpop.com', //正式
- target: 'http://211.149.199.65:5007', //测试
- ws: true,
- changeOrigin: true,
- rewrite: (p) => p.replace(/^\/dev-api/, ''),
- },
- },
- },
- resolve: {
- alias: {
- // 设置路径
- '~': path.resolve(__dirname, './'),
- // 设置别名
- '@': path.resolve(__dirname, './src'),
- '@assets': path.resolve(__dirname, './src/assets'),
- '@comps': path.resolve(__dirname, './src/components'),
- '@utils': path.resolve(__dirname, './src/utils'),
- '@store': path.resolve(__dirname, './src/store'),
- '@apis': path.resolve(__dirname, './src/api'),
- '@views': path.resolve(__dirname, './src/views'),
- '@hooks': path.resolve(__dirname, './src/hooks'),
- },
- },
- build: {
- outDir: 'hn-kdbooss-admin-dist', // 这里可以指定你想要的打包文件夹名
- rollupOptions: {
- output: {
- manualChunks(id) {
- if (id.includes('element-plus/theme')) {
- return 'ele'
- }
- },
- },
- }
- },
- }
- })
|