import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import fs from "fs";

// https://vitejs.dev/config/
export default defineConfig({
	plugins: [vue()],
	resolve: {
		alias: {
			"@": path.resolve(__dirname, "src"),
		},
	},
	server: {
		host: "jpcj-h5.zzxcx.net",
		port: 443,
		https: {
			key: fs.readFileSync("./cert/6353984_jpcj-h5.zzxcx.net.key"),
			cert: fs.readFileSync("./cert/6353984_jpcj-h5.zzxcx.net.pem"),
		},
		proxy: {
			"/dev-api": {
				target: "https://jpcj-admin1.zzxcx.net/twzd-admin",
				changeOrigin: true,
				rewrite: (path) => path.replace(/^\/dev-api/, ""),
			},
			"/prod-api": {
				target: "http://1.15.29.64:8080/twzd-admin",
				changeOrigin: true,
				rewrite: (path) => path.replace(/^\/prod-api/, ""),
			},
		},
	},
});
