Comments (3)
@rschristian , thanks for the quick reply!
You're absolutely right--this is simply a case of me not knowing about the 200.html
file.
Looks like I can get the behavior I'm looking for by using Vercel rewrites. In case anyone else is running into this, here's my vercel.json
config to avoid a flash of green homepage content on dynamic podcast-specific pages (e.g. adblockpodcast.com/podcast/1549059398).
{
"rewrites": [
{
"source": "/podcast/*",
"destination": "200.html"
}
]
}
It turns out all my pages share a header, so I was able to get a more complete page shell rendered (without content) on dynamic pages by manually creating a blank loading route (e.g. routes/blank-ssr-page.tsx
), pre-rendering it, and then just changing destination
in the Vercel rewrite to "blank-ssr-page/index.html"
, e.g.
from preact-cli.
Hmm, I'm not really sure what you expect CLI to do here? We just output static files, how you serve them is mostly out of scope.
there ought to be a way to control what pre-rendered content is used (instead of it having to be the homepage).
This is entirely up to your file server's configuration. Most file servers fallback to /index.html
, sounds like you instead want to configure /200.html
as your fallback.
Edit:
but it appears this fix is no longer working, or only applies after the service worker is installed.
Yes, you cannot use the service worker's cache if the service worker is not yet installed.
Edit2: To be clear, the role of /200.html
is to provide an empty shell to render into when offline or a network request for a page fails. If you start up your server (npm run serve
), navigate to it (to load the SW), stop your server, then navigate to say http://localhost:8080/example
, the SW will render your app into /200.html
(can check the network). This of course is meant to service PWAs, but you can use it as a empty shell fallback if you want, I suppose.
from preact-cli.
We can definitely do with some better docs here, will add it to the list.
from preact-cli.
Related Issues (20)
- compiling✖ ERROR Error: Babel-loader config not found!!! HOT 9
- Pages duplicate when accessing with /index.html HOT 9
- Brotli build - outputs content to same filename HOT 4
- default project template doesn't work with Node v18 HOT 4
- ERROR Error: error:0308010C:digital envelope routines::unsupported HOT 1
- Duplicated content when using /routes when using CLI v4 HOT 5
- Add Typescript increasses the bundle size HOT 4
- Can't resolve 'preact-cli-entrypoint' HOT 4
- Exported rest param syntax functions create invalid build JS HOT 4
- preact-cli hangs after "✔ Done!" HOT 5
- CSS source maps missing in build output HOT 3
- Typescript v5.1.6 compatibility HOT 2
- Route code-splitting breaks lazy loading of images HOT 3
- Use esbuild instead of babel HOT 2
- Fail to build due to `property missing ':'` when inline style HOT 4
- "TypeError: Cannot read properties of undefined (reading 'call')" when trying to route split HOT 7
- OptimizeCssAssetsPlugin causes build to crash in Yarn PnP mode HOT 2
- Config file failure when adding plugins HOT 8
- build gets stuck at "after chunk asset optimization" HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from preact-cli.