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

export default defineConfig({
  plugins: [
    uni(),
    visualizer(),
  ],
  css: {
    preprocessorOptions: {
      scss: {
        silenceDeprecations: {
          'legacy-js-api': true,
          'color-functions': true,
          'import': true,
        },
      },
    },
  },
  server: {
    host: "192.168.3.53", // 和后端 IP 一致
    port: 8300, // 跟后端端口一样（关键）
    strictPort: true, // 端口占用直接报错
    proxy: {
      '/yos/rest': { // 直接代理后端路径
        target: 'http://61.164.207.46:8300', // 真实后端
        changeOrigin: true,
        cookieDomainRewrite: "192.168.3.53", // 修改 Set-Cookie 的 Domain
        rewrite: (path) => path.replace(/^\/yos\/rest/, '/yos/rest')
      },
    },
  },
});
