import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import UnoCSS from 'unocss/vite'
import { fileURLToPath, URL } from 'node:url'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
  const base = mode === 'production' ? '/cockpit/' : '/'
  return {
    base: base,
    plugins: [vue(), UnoCSS()],
    server: {
      host: '0.0.0.0',
      proxy: {
        '/api': {
          // target: 'http://store-manage.hmily.club',
          target: 'https://store.manage.zlgj168.com',
          changeOrigin: true,
          ws: true,
          rewrite: (path) => path.replace(/^\/api/, ''),
        }
      }
    },
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url))
      },
    },
  }
})
