45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import path from 'path';
|
|
import pkgs from './package.json';
|
|
import tailwindcss from '@tailwindcss/vite';
|
|
import dotenv from 'dotenv';
|
|
dotenv.config();
|
|
const isDev = process.env.NODE_ENV === 'development';
|
|
const plugins = [react(), tailwindcss()];
|
|
|
|
let target = process.env.VITE_API_URL || 'http://localhost:51015';
|
|
const apiProxy = { target: target, changeOrigin: true, ws: true, rewriteWsOrigin: true, secure: false, cookieDomainRewrite: 'localhost' };
|
|
let proxy = {
|
|
'/root/': apiProxy,
|
|
'/api': apiProxy,
|
|
'/client': apiProxy,
|
|
};
|
|
const ENV_BASE_NAME = process.env.BASE_NAME;
|
|
|
|
const _basename = ENV_BASE_NAME || pkgs.basename;
|
|
const basename = isDev ? undefined : `${_basename}`;
|
|
/**
|
|
* @see https://vitejs.dev/config/
|
|
*/
|
|
export default defineConfig(() => {
|
|
return {
|
|
plugins,
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
},
|
|
},
|
|
base: basename,
|
|
define: {
|
|
BASE_NAME: JSON.stringify(basename),
|
|
BUILD_TIME: JSON.stringify(new Date().toISOString()),
|
|
},
|
|
server: {
|
|
port: 7008,
|
|
host: '0.0.0.0',
|
|
proxy,
|
|
},
|
|
};
|
|
});
|