/*******
 * @Author: gcz saadmin@126.com
 * @Date: 2025-09-01 11:38:45
 * @LastEditors: gcz saadmin@126.com
 * @LastEditTime: 2025-09-01 13:58:23
 * @FilePath: \claudetest\vite.config.js
 * @Description: 
 * @
 */
import { defineConfig, loadEnv } from 'vite'
import { resolve } from 'path'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd(), '')

  return {
    plugins: [vue()],
    resolve: {
      alias: {
        '@': resolve(__dirname, 'src'),
        '@assets': resolve(__dirname, 'src/assets'),
        '@components': resolve(__dirname, 'src/components'),
        '@views': resolve(__dirname, 'src/views'),
        '@pages': resolve(__dirname, 'src/pages'),
        '@router': resolve(__dirname, 'src/router'),
        '@stores': resolve(__dirname, 'src/stores'),
        '@utils': resolve(__dirname, 'src/utils'),
        '@api': resolve(__dirname, 'src/api'),
        '@styles': resolve(__dirname, 'src/styles')
      }
    },
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: `@use "@/styles/variables.scss" as *;`
        }
      }
    },
    server: {
      host: '0.0.0.0',
      // port: 3000,
      open: true,
      proxy: {
        [env.VITE_APP_BASE_URL]: {
          target: 'https://webadmin.dev.dazesoft.cn/stage-api',
          changeOrigin: true,
          rewrite: (path) => path.replace(new RegExp(`^${env.VITE_APP_BASE_URL}`), '')
        }
      }
    },
    build: {
      outDir: `dist-${env.VITE_APP_ENV || mode}`,
      assetsDir: 'static',
      rollupOptions: {
        output: {
          chunkFileNames: 'static/js/[name]-[hash].js',
          entryFileNames: 'static/js/[name]-[hash].js',
          assetFileNames: 'static/[ext]/[name]-[hash].[ext]'
        }
      }
    }
  }
})