import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import {resolve} from "path"
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import {VantResolver} from '@vant/auto-import-resolver';
import UnoCSS from 'unocss/vite'
// https://vitejs.dev/config/
export default defineConfig({
    envDir: './env', // 自定义env目录
    server: {
        host: '0.0.0.0', // 监听所有网络接口
        port: 5878,
        // 选项写法
        proxy: {
            '/pag': {
                target: 'https://cdn.tmui.design',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, '/api')
            },
        }
    },
    plugins: [
        vue(),
        UnoCSS(),
        AutoImport({
            resolvers: [VantResolver()],
        }),
        Components({
            resolvers: [VantResolver()],
        }),
    ],
    resolve: {
        alias: [
            {
                find: "@",
                replacement: resolve(__dirname, 'src')
            }
        ]
    },
})
