import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";

import AutoImport from "unplugin-auto-import/vite";

import legacy from "@vitejs/plugin-legacy";
import { resolve } from "path";

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [
        uni(),
        AutoImport({
            imports: [
                "vue",
                "uni-app",
                {
                    "rexma-cli": ["xma"]
                }
            ],
            dts: "src/declaration/auto-imports.d.ts"
        }),
        process.env.UNI_PLATFORM === "h5" &&
            legacy({
                targets: ["defaults", "not IE 11"]
            })
    ].filter(Boolean),
    resolve: {
        alias: {
            "@": resolve(__dirname, "./src")
        }
    },

    server: {
        port: 8899
        // 代理配置
        /*         proxy: {
            "^/api": {
                target: "https://lygsh-api.wjzpgz.com", // 后端服务实际地址
                changeOrigin: true, //开启代理
                // path是请求方法axios配置的baseUr中去除 协议+域名+端口 剩下的部分。例如http://127.0.0.1:9000/api，这里的path就是/api
                rewrite: path => path.replace(/^\/api/, "") // 路径重写
            }
        } */
    }
});
