immich/web/vite.config.ts
Min Idzelis 54bc9ddd69
chore: add vitest project names and fix server config root paths (#26684)
Add `name` to all vitest configs matching CI job buckets (server:unit,
server:medium, cli:unit, web:unit, e2e:server, e2e:maintenance) so they
appear as filterable @tags in the Vitest VSCode extension.

Fix `root` in server vitest configs to use an absolute path derived from
`import.meta.url` instead of `'./'`, which resolved relative to the config
file directory (`server/test/`) rather than `server/`, causing test
discovery to fail in the Vitest VSCode extension.
2026-03-04 08:20:43 -05:00

72 lines
1.7 KiB
TypeScript

import { enhancedImages } from '@sveltejs/enhanced-img';
import { sveltekit } from '@sveltejs/kit/vite';
import tailwindcss from '@tailwindcss/vite';
import { svelteTesting } from '@testing-library/svelte/vite';
import path from 'node:path';
import { visualizer } from 'rollup-plugin-visualizer';
import { defineConfig, type ProxyOptions, type UserConfig } from 'vite';
const upstream = {
target: process.env.IMMICH_SERVER_URL || 'http://immich-server:2283/',
secure: true,
changeOrigin: true,
logLevel: 'info',
ws: true,
};
const proxy: Record<string, string | ProxyOptions> = {
'/api': upstream,
'/.well-known/immich': upstream,
'/custom.css': upstream,
};
export default defineConfig({
build: {
target: 'es2022',
},
resolve: {
alias: {
'xmlhttprequest-ssl': './node_modules/engine.io-client/lib/xmlhttprequest.js',
// eslint-disable-next-line unicorn/prefer-module
'@test-data': path.resolve(__dirname, './src/test-data'),
// '@immich/ui': path.resolve(__dirname, '../../ui'),
},
},
server: {
// connect to a remote backend during web-only development
proxy,
allowedHosts: true,
},
preview: {
proxy,
},
plugins: [
enhancedImages(),
tailwindcss(),
sveltekit(),
process.env.BUILD_STATS === 'true'
? visualizer({
emitFile: true,
filename: 'stats.html',
})
: undefined,
svelteTesting(),
],
optimizeDeps: {
entries: ['src/**/*.{svelte,ts,html}'],
},
test: {
name: 'web:unit',
include: ['src/**/*.{test,spec}.{js,ts}'],
globals: true,
environment: 'happy-dom',
setupFiles: ['./src/test-data/setup.ts'],
sequence: {
hooks: 'list',
},
env: {
TZ: 'UTC',
},
},
} as UserConfig);