Serving a PWA manifest and service worker through the Rails view layer
The app itself. The README is the stock Rails placeholder, so the tree is the record.
The two files that make it worth a note are app/views/pwa/manifest.json.erb
and app/views/pwa/service-worker.js: a Rails 8 app serving its PWA surface
through the view layer rather than as static assets. Rendering the manifest
through ERB means it can vary per account and take its theme colour from the
same place the app’s theme switcher reads, and it gets Rails routing and caching
like any other response. A static manifest cannot do that without a build step.
The service worker is the half needing care. Its scope is constrained by the
path it is served from, so serving it through the app means being deliberate
about the route and the Service-Worker-Allowed header rather than getting root
scope free. Propshaft fingerprinting is the other trap: a fingerprinted service
worker is one the browser treats as a new worker on every deploy.
Devise, importmaps and Tailwind underneath, with CI, Dependabot, RuboCop and a Dockerfile wired from the start.