42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import path from 'path';
|
|
import pkgs from './package.json';
|
|
import dotenv from 'dotenv';
|
|
dotenv.config();
|
|
const isDev = process.env.NODE_ENV === 'development';
|
|
const plugins: any = [];
|
|
|
|
let target = process.env.VITE_API_URL || 'http://localhost:51515';
|
|
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({
|
|
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: '::',
|
|
allowedHosts: true,
|
|
proxy,
|
|
},
|
|
});
|