fix: make downloaded ZIP + double-click index.html actually work offline, chore: declare MIT license in package.json metadata, - #46
Conversation
Option B in the README ("download the ZIP, open index.html") was silently
broken in every modern browser. Two stacked file:// CORS restrictions
caused it: <script type="module"> is blocked under file://, and even after
working around that, runtime fetch('config.json') is also blocked under
file:// regardless of script type — so the app could never load its
starter departments/tasks when opened by double-click.
Fix is build-only, so the two supported paths stay independent:
- Production build (npm run build) now inlines config.json into dist/index.html
as window.__PM_OPS_CONFIG__ via a new HtmlWebpackPlugin beforeEmit hook, and
swaps the entry script tag to a plain deferred script (the webpack bundle is
already a classic IIFE with no import/export, so type="module" served no
purpose there).
- js/app.js checks for window.__PM_OPS_CONFIG__ first and falls back to the
original fetch('config.json') otherwise, so the raw source served by GitHub
Pages / npm start / any real HTTP server is untouched and unaffected.
Verified with Playwright directly against the built dist/index.html:
- Loaded over file:// with zero console/network errors, window.__PM_OPS_CONFIG__
present, all 262 starter tasks rendered.
- Data survives a full browser close and reopen under file:// (same as the
already-working hosted-over-HTTP case): set company name in one browser
process, closed it entirely, reopened with the same profile, onboarding did
not reappear and the company name + all task rows were still there.
- Raw source served over plain HTTP (GitHub Pages / npm start equivalent)
still loads with zero errors, confirming the fetch() fallback path is intact.
- npm test: 85/85 passing.
LICENSE.txt and the README badge already say MIT; package.json was missing the license field GitHub's license detector and npm tooling read, which could make the project look unlicensed to those tools.
hypnoticdata777
left a comment
There was a problem hiding this comment.
Commit 0095546 — fix: make downloaded ZIP + double-click index.html actually work offline
What it was: The README's "Option B" (download the ZIP, double-click index.html) never actually worked. Opening the file directly uses the file:// protocol, which every modern browser blocks in two ways: it won't run <script type="module">, and even if it did, it won't let fetch() read a local file like config.json. So the app's departments/tasks (which come from config.json) could never load — the page would just sit there broken, with no visible error unless you opened dev tools.
What we changed:
webpack.config.prod.js: added a build step that bakes config.json's contents directly into dist/index.html as a JS variable (window.PM_OPS_CONFIG), and swaps the script tag from type="module" to a regular script — only in the built output.
js/app.js: on startup, it now checks for that baked-in variable first, and only falls back to fetch('config.json') if it's not there.
This only affects the production build (npm run build / the ZIP people download). The raw source code (what GitHub Pages serves, or what runs via npm start) is untouched and still uses fetch() like before.
Verified: Built the app, opened the built index.html directly via file:// — loads cleanly with no errors, all tasks show up. Also confirmed data still saves and reloads correctly after fully closing and reopening the browser. Ran the test suite (85 tests) — all passing. Also double-checked GitHub Pages / npm start still works unaffected.
No description provided.