import {defineConfig} from 'vite'
import uni from "@dcloudio/vite-plugin-uni";
import Unocss from 'unocss/vite'
import {resolve} from "path";
import website from './config/index';

export default defineConfig({
    resolve: {
        alias: {
            '~api': resolve(__dirname, './httpApi/modules'),
        }
    },
    plugins: [
        uni(),
        Unocss(),
    ],
    server: {
        ...website.vite,
        proxy: {
            '/api': {
                ws: true,
                changeOrigin: true,
                target: () => {
                    return process.env.NODE_ENV === 'development' ? website.testApi : website.baseApi
                },
                rewrite: (path) => path.replace(new RegExp('^/api'), '/'),
            }
        }
    },
})
