GCodeOverlay/vite.config.ts

24 lines
947 B
TypeScript
Raw Normal View History

import { defineConfig } from 'vitest/config';
// Minimal Node global declaration so tsc resolves `process.env` below without pulling in
// the full @types/node package (tsconfig pins `types` to vitest/globals only).
declare const process: { env: Record<string, string | undefined> };
export default defineConfig({
// Dev-only: proxy the CNC MJPEG camera so the page can load it via a
// same-origin relative path (`/camera/...`), exactly as nginx does in
// production. Keeps `streamUrl` identical in dev and prod and avoids
// mixed-content / cross-origin issues. Override the target for a different
// camera with: VITE_CAMERA_TARGET=http://host npm run dev
server: {
proxy: {
'/camera': {
target: process.env.VITE_CAMERA_TARGET || 'http://172.17.3.38',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/camera/, ''),
},
},
},
test: { globals: true, environment: 'node' },
});