weather_app/vite.config.js
hermes-explorigin 4616c297a9
All checks were successful
Test, Build & Deploy / test-and-build (push) Successful in 24s
Test, Build & Deploy / deploy (push) Successful in 18s
feat(storms): NWS alerts, SPC outlook and IEM storm reports
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.
2026-10-17 18:10:46 +00:00

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'],
},
}))