feat(kiosk): implement kiosk report submission functionality with offline support test(outbox): add tests for outbox functionality including report submission and error handling feat(outbox): create outbox management for queued reports with IndexedDB persistence feat(uuid): add UUID generation utility for client IDs feat(qr): implement QR code generation for reporting links by site and area feat(kiosk): create Kiosk page for reporting incidents without an account
66 lines
2.5 KiB
TypeScript
66 lines
2.5 KiB
TypeScript
/// <reference types="vitest/config" />
|
|
import react from '@vitejs/plugin-react'
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
import { readFileSync } from 'node:fs'
|
|
import { defineConfig } from 'vite'
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
|
|
|
const { version } = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')) as { version: string }
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
react(),
|
|
tailwindcss(),
|
|
// Installable app + offline shell. Service workers need HTTPS (or localhost).
|
|
VitePWA({
|
|
registerType: 'autoUpdate',
|
|
includeAssets: ['favicon.svg', 'icons/apple-touch-icon.png'],
|
|
manifest: {
|
|
name: 'Open SafetyLog EHS',
|
|
short_name: 'SafetyLog',
|
|
description: 'Report hazards, near misses and incidents, and follow them through to closure.',
|
|
theme_color: '#163c37',
|
|
background_color: '#f7f8f5',
|
|
display: 'standalone',
|
|
start_url: '/',
|
|
scope: '/',
|
|
icons: [
|
|
{ src: '/icons/icon-192.png', sizes: '192x192', type: 'image/png' },
|
|
{ src: '/icons/icon-512.png', sizes: '512x512', type: 'image/png' },
|
|
{ src: '/icons/maskable-512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' },
|
|
],
|
|
shortcuts: [{ name: 'Report an incident', url: '/report', icons: [{ src: '/icons/icon-192.png', sizes: '192x192' }] }],
|
|
},
|
|
workbox: {
|
|
globPatterns: ['**/*.{js,css,html,svg,png,woff2}'],
|
|
navigateFallback: '/index.html',
|
|
navigateFallbackDenylist: [/^\/api\//],
|
|
runtimeCaching: [
|
|
{
|
|
// Just enough to open the report form offline: who you are, and the list of sites/areas.
|
|
urlPattern: ({ url }) => ['/api/auth/me', '/api/sites', '/api/kiosk/config'].includes(url.pathname),
|
|
handler: 'NetworkFirst',
|
|
options: { cacheName: 'api-essentials', networkTimeoutSeconds: 5, expiration: { maxEntries: 20, maxAgeSeconds: 7 * 24 * 60 * 60 } },
|
|
},
|
|
],
|
|
},
|
|
}),
|
|
],
|
|
define: { __APP_VERSION__: JSON.stringify(version) },
|
|
server: {
|
|
proxy: { '/api': 'http://localhost:3000' },
|
|
},
|
|
test: {
|
|
projects: [
|
|
{
|
|
extends: true,
|
|
test: { name: 'web', environment: 'jsdom', globals: true, setupFiles: ['./src/test/setup.ts'], include: ['src/**/*.test.{ts,tsx}'] },
|
|
},
|
|
{
|
|
test: { name: 'server', environment: 'node', globals: true, testTimeout: 30_000, hookTimeout: 30_000, include: ['server/**/*.test.ts', 'shared/**/*.test.ts'] },
|
|
},
|
|
],
|
|
},
|
|
})
|