generated from template/astro-template
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import path from 'path';
|
|
import tailwindcss from '@tailwindcss/vite';
|
|
const plugins = [react(), tailwindcss()];
|
|
let target = process.env.VITE_API_URL || 'https://kevisual.xiongxiao.me';
|
|
console.log('API Target:', target);
|
|
const apiProxy = { target: target, changeOrigin: true, ws: true, rewriteWsOrigin: true, secure: false, cookieDomainRewrite: 'localhost' };
|
|
let proxy = {
|
|
'/root/': apiProxy,
|
|
'/user/login/': apiProxy,
|
|
'/api': apiProxy,
|
|
'/client': apiProxy,
|
|
};
|
|
/**
|
|
* @see https://vitejs.dev/config/
|
|
*/
|
|
export default defineConfig(() => {
|
|
return {
|
|
plugins,
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, '../../src'),
|
|
},
|
|
},
|
|
base: './',
|
|
define: {
|
|
DEV_SERVER: JSON.stringify(process.env.NODE_ENV === 'development'),
|
|
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
|
},
|
|
build: {
|
|
target: 'modules',
|
|
},
|
|
server: {
|
|
port: 7009,
|
|
host: '0.0.0.0',
|
|
allowedHosts: true,
|
|
proxy,
|
|
},
|
|
};
|
|
});
|