mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 18:52:56 +00:00
update
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import { defineConfig, loadEnv } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
|
||||
function buildProcessEnv(mode: string, env: Record<string, string>, base: string) {
|
||||
const processEnv: Record<string, string> = {
|
||||
NODE_ENV: mode === 'production' ? 'production' : mode,
|
||||
PUBLIC_URL: base === '/' ? '' : base.replace(/\/$/, ''),
|
||||
};
|
||||
|
||||
for (const [key, value] of Object.entries(env)) {
|
||||
if (key.startsWith('REACT_APP_')) {
|
||||
processEnv[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return processEnv;
|
||||
}
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), '');
|
||||
const base = env.PUBLIC_URL ? (env.PUBLIC_URL.endsWith('/') ? env.PUBLIC_URL : `${env.PUBLIC_URL}/`) : '/';
|
||||
const processEnv = buildProcessEnv(mode, env, base);
|
||||
|
||||
return {
|
||||
base,
|
||||
publicDir: 'public',
|
||||
plugins: [react()],
|
||||
define: {
|
||||
'process.env': JSON.stringify(processEnv),
|
||||
global: 'globalThis',
|
||||
},
|
||||
build: {
|
||||
outDir: 'build',
|
||||
assetsDir: 'static',
|
||||
emptyOutDir: true,
|
||||
sourcemap: false,
|
||||
},
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: 3100,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://127.0.0.1:8082',
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
preview: {
|
||||
host: '0.0.0.0',
|
||||
port: 4174,
|
||||
},
|
||||
test: {
|
||||
environment: 'jsdom',
|
||||
globals: true,
|
||||
},
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user