12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- 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();
- console.log('Environment Variables:', import.meta.env);
- interface ImportMetaEnv {
- readonly VITE_API_URL: string; // 示例环境变量
- }
- interface ImportMeta {
- readonly env: ImportMetaEnv;
- }
- console.log('Environment Variables:', import.meta.env);
- 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),
- },
- // 配置前端服务地址和端口
- 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/, '')
- },
- }
- },
- });
|