test: keep Vite env helper in frontend project
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
export const mergeViteEnv = (
|
||||
fileEnv: Record<string, string>,
|
||||
runtimeEnv: NodeJS.ProcessEnv
|
||||
): Record<string, string | undefined> => ({
|
||||
...fileEnv,
|
||||
...runtimeEnv,
|
||||
});
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user