import { defineConfig, loadEnv } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import pkg from "./package.json";

export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, __dirname);
  // console.log(env);
  return {
    build: {
      minify: "terser",
      terserOptions: {
        compress: {
		  // 移除console
          drop_console: false,
          drop_debugger: true,
        },
      },
    },
    define: {
      __APP_INFO__: JSON.stringify({
        pkg,
        buildTimestamp: Date.now(),
      }),
    },
    plugins: [uni()],
    server: {
      port: Number.parseInt(env.VITE_APP_PORT, 10),
      proxy: {
        ['/jsonrpc']: {
          changeOrigin: true,
          target: 'https://lift-drawing-h5.ruixininfo.com',
          // target: 'https://lift-h5.shulinelev.com',
          // target: 'https://lift-drawing.ruixininfo.com',
        },
        ['/api/proxyDownload']: {
          changeOrigin: true,
          target: 'https://lift-drawing-h5.ruixininfo.com',
          // target: 'https://lift-h5.shulinelev.com',
          // target: 'https://lift-drawing.ruixininfo.com',
        },
      },
    },
  };
});
