import { fileURLToPath, URL } from "node:url"

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

// https://vitejs.dev/config/
export default defineConfig({
  base: "",
  plugins: [vue()],
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `
          @use "@/assets/styles/variable.scss" as *;
          @use "@/assets/styles/mixin.scss" as *;
        `
      }
    }
  },
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url))
    }
  },
  server: {
    port: 9527,
    host: "0.0.0.0",
    proxy: {
      // 正则表达式写法
      "^/pptApi/.*": {
        target: "https://test.kt.colexiu.com",
        changeOrigin: true,
        rewrite: path => path.replace(/^\/pptApi/, "")
      }
    }
  }
})
