Two things people asked for on release day, both small, both awkward to live without. The version was not visible anywhere. mflova asked how to tell which build the phone app is running and andi242 said he had wondered the same that morning; issue #7 asks for it too. The support template in #install-help has been telling people to read it off "the bottom of Settings" — where it was not. It is there now, read from package.json at build time so it cannot drift from the release it shipped in. On the phone there is no address bar and no about box, so this was the only missing way to answer "did the update actually install". The rest timer had no off switch. andi242, in the per-exercise-timers thread: "I don't use rest timers, so I find it's a bit tedious to skip the timer every time." v1.2.10 made that worse rather than better — it now rests after every set except the last of the session, so an exercise that used to end quietly no longer does, and there was still no way out. "Off" now sits at the top of the same list as 60/90/120/150/180. The guard is inside startRest rather than at the four places that call it, for the same reason the rest-after-a-set rule became one shared condition: a rule that has to be repeated is a rule that gets forgotten. 'Off' already exists in all twelve locale packs, so this adds no translation work.
50 lines
2.1 KiB
JavaScript
50 lines
2.1 KiB
JavaScript
import { readFileSync } from 'node:fs'
|
|
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
const backend = process.env.API_TARGET || 'http://127.0.0.1:3000'
|
|
// The API refuses a state-changing request that a browser sent from anywhere other than its own
|
|
// ORIGIN (the CSRF guard in api/server.js). The dev server is on a different port, so the page's
|
|
// real Origin is not ORIGIN — modern browsers get through on Sec-Fetch-Site: same-origin, and
|
|
// presenting the expected Origin here covers the ones that don't send it. Match your .env if you
|
|
// changed ORIGIN: API_ORIGIN=https://gym.example.com npm run dev
|
|
const apiOrigin = process.env.API_ORIGIN || 'http://localhost:8080'
|
|
const media = process.env.MEDIA_TARGET || 'http://127.0.0.1:8888'
|
|
|
|
// Optional web analytics (Umami). Injected only when BOTH vars are set at build time,
|
|
// so a plain `npm run build` — and every self-hosted install — stays telemetry-free.
|
|
// Set for the public instance: VITE_UMAMI_SRC=https://stats.example/script.js VITE_UMAMI_ID=<uuid>
|
|
const umamiSrc = process.env.VITE_UMAMI_SRC
|
|
const umamiId = process.env.VITE_UMAMI_ID
|
|
|
|
const umami = {
|
|
name: 'opengym-umami',
|
|
transformIndexHtml() {
|
|
if (!umamiSrc || !umamiId) return
|
|
return [{
|
|
tag: 'script',
|
|
attrs: { defer: true, src: umamiSrc, 'data-website-id': umamiId },
|
|
injectTo: 'head'
|
|
}]
|
|
}
|
|
}
|
|
|
|
// The version people are asked for in #install-help and on every bug report. Read from
|
|
// package.json so it cannot drift from the release it was built in, and inlined at build
|
|
// time so no runtime fetch is involved.
|
|
const pkgVersion = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')).version
|
|
|
|
export default defineConfig({
|
|
define: { __APP_VERSION__: JSON.stringify(pkgVersion) },
|
|
plugins: [react(), umami],
|
|
base: './',
|
|
server: {
|
|
proxy: {
|
|
'/api': { target: backend, changeOrigin: true, headers: { Origin: apiOrigin } },
|
|
'/img': { target: media, changeOrigin: true },
|
|
'/gif': { target: media, changeOrigin: true }
|
|
}
|
|
},
|
|
build: { chunkSizeWarningLimit: 1500 }
|
|
})
|