import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import legacy from "@vitejs/plugin-legacy";
import { resolve } from "path";
import postCssPxToRem from "postcss-pxtorem";
import { createStyleImportPlugin } from "vite-plugin-style-import";
import components from "unplugin-vue-components/vite";
import autoImport from "unplugin-auto-import/vite";
import { VarletUIResolver, NaiveUiResolver } from "unplugin-vue-components/resolvers";

// https://vitejs.dev/config/
export default defineConfig({
  base: "./",
  resolve: {},
  plugins: [
    // mkcert(), // 本地https
    legacy({
      targets: "last 2 versions and not dead, > 0.3%, Firefox ESR",
    }),
    vue(),
    vueJsx(),
    // components({
    // 	resolvers: [NaiveUiResolver()],
    // })
  ],
  css: {
    postcss: {
      plugins: [
        // postCssPxToRem({
        // 	rootValue: 37.5,
        // 	propList: ["*"],
        // 	selectorBlackList: [".norem"],
        // }),
      ],
    },
  },
  build: {
    rollupOptions: {
      input: {
        index: resolve(__dirname, "index.html"),
      },
    },
  },
  server: {
    cors: true,
    port: 3050,
    // https: true,
    proxy: {
      "^/edu-app/.*": {
        target: "https://test.lexiaoya.cn",
        // target: "https://dev.kt.colexiu.com",
        changeOrigin: true,
        // rewrite: (path) => path.replace(/^\/edu-app/, ""),
      },
    },
  },
});
// vite.config.js