fuzzyworld

when-am-i / files / vite.config.ts

vite.config.ts

Blame: the commit that last changed each line · file · history

60741172 2026-06-17 Pavel Safronov1/// <reference types="vitest/config" />
e6fe2bc7 2026-06-17 Pavel Safronov2import { execSync } from 'node:child_process';
3import { readFileSync } from 'node:fs';
edbab6ce 2026-03-20 Pavel Safronov4import { defineConfig } from 'vite';
5import react from '@vitejs/plugin-react';
c2d75cfd 2026-10-27 Pavel Safronov6import fuzzyworld from 'fuzzyworld-tools/vite';
edbab6ce 2026-03-20 Pavel Safronov7
e6fe2bc7 2026-06-17 Pavel Safronov8// Build metadata, surfaced in error reports so we know which deployed build a
9// report came from. Commit falls back to "unknown" outside a git checkout (CI
10// without history, tarball builds, etc.).
11const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf-8'));
12const gitCommit = (() => {
13 if (process.env.CI_COMMIT_SHORT_SHA) return process.env.CI_COMMIT_SHORT_SHA;
14 try {
15 return execSync('git rev-parse --short HEAD').toString().trim();
16 } catch {
17 return 'unknown';
18 }
19})();
20
edbab6ce 2026-03-20 Pavel Safronov21export default defineConfig({
c2d75cfd 2026-10-27 Pavel Safronov22 plugins: [fuzzyworld(), react()],
e6fe2bc7 2026-06-17 Pavel Safronov23 define: {
24 __APP_VERSION__: JSON.stringify(pkg.version),
25 __GIT_COMMIT__: JSON.stringify(gitCommit),
26 __BUILD_TIME__: JSON.stringify(new Date().toISOString()),
27 },
60741172 2026-06-17 Pavel Safronov28 server: {
29 // Bind/open on 127.0.0.1 rather than `localhost`. Some browsers (e.g.
30 // Firefox here) pin `localhost` to HTTPS via HSTS — set by other local
31 // projects that serve HTTPS dev servers — and then force-upgrade every
32 // http://localhost request, which fails against Vite's plain-HTTP dev
33 // server (NS_ERROR_NET_EMPTY_RESPONSE). HSTS is per-hostname, so
34 // 127.0.0.1 is unaffected. A CLI `--host` still overrides this.
35 host: '127.0.0.1',
36 },
edbab6ce 2026-03-20 Pavel Safronov37 build: {
38 outDir: 'dist',
39 },
60741172 2026-06-17 Pavel Safronov40 test: {
41 // Engine tests are pure (no DOM); the default node environment is fine.
42 environment: 'node',
43 include: ['src/**/*.test.ts'],
44 },
edbab6ce 2026-03-20 Pavel Safronov45});