import { defineConfig } from 'vite'
import Uni from '@dcloudio/vite-plugin-uni'
import UniKuRoot from '@uni-ku/root'
import { resolve } from "path"
export default async () => {
  const UnoCSS = (await import('unocss/vite')).default

  return defineConfig({
    envDir: './env', // 自定义env目录
    resolve: {
      alias: [
        {
          find: "@",
          replacement: resolve(__dirname, 'src')
        }
      ]
    },
    server: {
      host: '0.0.0.0', // 监听所有网络接口
      port: 2367,
      // 选项写法
      proxy: {
        '/pag': {
          target: 'https://cdn.tmui.design',
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, '/api')
        },
      }
    },
    plugins: [
      Uni(),
      UniKuRoot(),
      UnoCSS()
    ],
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: `@import "@/static/css/color.scss";`,
        },
      },
    }
  })
}
