import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import AutoImport from 'unplugin-auto-import/vite'
import { svgBuilder } from '/@/components/icon/svg/index'

import path from 'path'

const nodeResolve = (dir: string): any => path.resolve(__dirname, '.', dir)
// https://vitejs.dev/config/
export default defineConfig({
    plugins: [
        vue(),
        svgBuilder('./src/assets/icons/'),
        vueJsx(),
        AutoImport({
            //自动引入
            imports: ['vue', 'vue-router', 'pinia']
        })
    ],
    server: {
        host: '0.0.0.0',
        open: true,
        port:5174,
        proxy: {
            '/api': {
                // target: 'http://10.95.53.49:10215', //海南服务器ip
                // target: 'http://10.118.135.128:10215', ///hsw
                target: 'http://192.168.1.29:10215', ///hsw
                // target: 'http://192.168.1.68:10215', ///hsw
                //  target: 'http://10.119.65.152:10215', //数据中心
                changeOrigin: true,
                rewrite: path => path.replace(/^\/api/, '') //路径重写，把'/api'替换为''
            },
            '/api-docx': {
                // 文件服务器地址
                target: 'http://192.168.1.29:9009',
                changeOrigin: true,
                rewrite: path => path.replace(/^\/api-docx/, '')
            },
            '/map': {
                // target: 'http://10.95.53.49:8088', //海南服务器ip
                target: 'http://192.168.1.125:9009', //hsw
                // target: 'http://192.168.1.125:8088', //数据中心
                changeOrigin: true
            }
        }
    },
    resolve: {
        alias: {
            '/@': nodeResolve('.src'),
            '@': nodeResolve('src'),
            '~': nodeResolve('public')
        }
    }
})
    