import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';
import dotenv from 'dotenv';
import VueI18n from '@intlify/vite-plugin-vue-i18n';

// 加载环境变量
dotenv.config();
interface ImportMetaEnv {
    readonly VITE_API_URL: string; // 示例环境变量
}

interface ImportMeta {
    readonly env: ImportMetaEnv;
}
export default defineConfig({
    plugins: [
        vue(),
        VueI18n({
            include: path.resolve(__dirname, './src/locales/**'),
        }),
    ],
     // 配置前端服务地址和端口
     server: {
        host: '0.0.0.0',
        port: 5173,
        // 是否开启 https
        https: false,
        // 设置反向代理，跨域
        proxy: {
            '/api1': {
                // 后台地址
                target: 'http://127.0.0.1:8990/',
                changeOrigin: true,
                rewrite: path => path.replace(/^\/api1/, '')
            },
        }
    },
    resolve: {
        alias: {
            '@': path.resolve(__dirname, './src'),
        },
    },
    optimizeDeps: {
        include: ['quill'],
    },
    define: {
        //__API_URL__: JSON.stringify(process.env.VITE_API_URL),
    },
    
});
