123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import { defineConfig } from 'vite';
- import vue from '@vitejs/plugin-vue';
- import path from 'path';
- import vueI18n from '@intlify/vite-plugin-vue-i18n';
- import dotenv from 'dotenv';
- // 加载环境变量
- 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/**'),
- }),
- ],
- resolve: {
- alias: {
- '@': path.resolve(__dirname, './src'),
- },
- },
- optimizeDeps: {
- include: ['quill'],
- },
- define: {
- __API_URL__: JSON.stringify(process.env.VITE_API_URL),
- __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false'
- },
- // 配置前端服务地址和端口
- server: {
- host: '0.0.0.0',
- port: 5173,
- https: false,
- proxy: {
- '/api': {
- target: 'http://192.168.1.141:18082',
- changeOrigin: true,
- rewrite: (path) => path.replace(/^\/api/, ''),
- },
- },
- },
- });
|