test: keep Vite env helper in frontend project

This commit is contained in:
2026-08-05 00:43:50 +00:00
parent 58f5e1102f
commit e86a23f749
3 changed files with 9 additions and 9 deletions
+7
View File
@@ -0,0 +1,7 @@
export const mergeViteEnv = (
fileEnv: Record<string, string>,
runtimeEnv: NodeJS.ProcessEnv
): Record<string, string | undefined> => ({
...fileEnv,
...runtimeEnv,
});
+1 -1
View File
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { mergeViteEnv } from '../vite.config.ts';
import { mergeViteEnv } from '../src/config/viteEnv.ts';
void describe('game frontend Vite config', () => {
void it('prefers managed runtime values over values loaded from env files', () => {
+1 -8
View File
@@ -2,6 +2,7 @@ import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
import tailwindcss from '@tailwindcss/vite';
import path from 'path';
import { mergeViteEnv } from './src/config/viteEnv';
const normalizeBasePath = (value: string | undefined): string => {
const pathValue = (value ?? '/').trim();
@@ -23,14 +24,6 @@ const resolvePreviewAllowedHosts = (value: string | undefined): true | string[]
return hosts;
};
export const mergeViteEnv = (
fileEnv: Record<string, string>,
runtimeEnv: NodeJS.ProcessEnv
): Record<string, string | undefined> => ({
...fileEnv,
...runtimeEnv,
});
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = mergeViteEnv(loadEnv(mode, process.cwd(), ''), process.env);