Adds a Storms tab driven by three keyless, CORS-enabled feeds: - api.weather.gov/alerts/active?point=… for watches/warnings/advisories, with a banner above the content for tornado/severe/Extreme alerts - SPC Day 1-3 categorical outlooks plus Day 1 tornado/hail/wind probabilities, resolved by point-in-polygon (nolyr GeoJSON) - NWS Local Storm Reports via IEM (bounding box + radius cut), nearest first New: src/lib/api/storm.js (pure helpers + cached fetchers), src/lib/stores/storm.svelte.js (5-min polling, stale-response guard), src/components/StormWatch.svelte. Router/nav gain a 'storms' view. Tests: geometry/parsing (16), store (7), component render (3). Docs: AGENTS.md storm section + API notes.
59 lines
1.8 KiB
JavaScript
59 lines
1.8 KiB
JavaScript
import { execSync } from 'node:child_process'
|
|
import { defineConfig } from 'vite'
|
|
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
|
import { viteSingleFile } from 'vite-plugin-singlefile'
|
|
|
|
// https://vite.dev/config/
|
|
// Bake the commit hash into the bundle at build time so a deployed app can
|
|
// report exactly which commit produced it (logged via console.info at startup).
|
|
// CI sets VITE_COMMIT_HASH=${{ github.sha }}; local builds fall back to git HEAD.
|
|
function getCommitHash() {
|
|
if (process.env.VITE_COMMIT_HASH) return process.env.VITE_COMMIT_HASH
|
|
try {
|
|
return execSync('git rev-parse HEAD').toString().trim()
|
|
} catch {
|
|
return 'unknown'
|
|
}
|
|
}
|
|
|
|
export default defineConfig(({ command, mode }) => ({
|
|
define: {
|
|
__WEATHER_COMMIT__: JSON.stringify(getCommitHash()),
|
|
},
|
|
plugins: [
|
|
svelte(),
|
|
...(command === 'build'
|
|
? [viteSingleFile({
|
|
inlineStyles: true,
|
|
inlineScripts: true,
|
|
removeUnusedCss: true,
|
|
removeViteModuleLoader: true,
|
|
})]
|
|
: []),
|
|
],
|
|
build: {
|
|
target: 'esnext',
|
|
minify: false,
|
|
rollupOptions: {
|
|
treeshake: {
|
|
moduleSideEffects: true,
|
|
annotations: false,
|
|
},
|
|
},
|
|
},
|
|
preview: {
|
|
allowedHosts: ["dev.thecookiejar.me"]
|
|
},
|
|
// Vitest runs with mode 'test'; resolving the browser builds of Svelte is
|
|
// what makes client-side `mount()` available in component tests. Leave the
|
|
// build untouched — forcing conditions here breaks the production bundle
|
|
// (Svelte's server entry gets picked and mount() throws).
|
|
resolve: mode === 'test' ? { conditions: ['browser'] } : undefined,
|
|
test: {
|
|
environment: 'jsdom',
|
|
globals: true,
|
|
setupFiles: ['./tests/setup.js'],
|
|
include: ['src/**/*.test.js', 'tests/**/*.test.js'],
|
|
},
|
|
}))
|