-
-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full offline support, precacheConfig vs prerender-urls.json etc... #475
Comments
Hey~! You need to specify a list of URLs to prerender inside your If you have a known set of // known set
//~> assumes you only have "edit/foo" and "edit/bar"
[
{
"url": "/",
"title": "Home",
"description": "Foobar"
}, {
"url": "/profile",
"title": "Profile",
"description": "This is profile"
}, {
"url": "/edit/foo",
"title": "Log Edit: Foo",
"description": "Editing Foo"
}, {
"url": "/edit/bar",
"title": "Log Edit: Bar",
"description": "Editing Bar"
}
]
// Dynamic, leave as template
[
{
"url": "/",
"title": "Home",
"description": "Foobar"
}, {
"url": "/profile",
"title": "Profile",
"description": "This is profile"
}, {
"url": "/edit",
"isEdit": true
}
] Then you can customize your template file, responding to the <!-- COPY MOST OF OUR TEMPLATE -->
<!-- SOMEWHERE INSIDE HEAD -->
<% if (htmlWebpackPlugin.options.isEdit) { %>
<title>Editing {INSERT_EDIT_NAME)</title>
<meta property="og:url" content="https://example.com/edit/{INSERT_EDIT_PATH}">
<% } else { %>
<title><%= htmlWebpackPlugin.options.title %></title>
<meta property="og:url" content="https://example.com/<%= htmlWebpackPlugin.options.url %>">
<% } %> During SSR, you'd readout the contents of Your final $ preact build --prerenderUrls prerender-urls.json --template src/template.html |
Ok, thanks. My whole app is a Preact app so there aren't many template files to modify, but if I just change the edit route to |
Great! FYI, the template file I'm referring to is this file, which is used by default. If you need to make template changes, you'd copy this file manually (for now) and then pass the |
For some reason it wasn't quite working yet (did another build and release, and it no longer loads the other routes on the initial load for some reason). But something is fishy because there is also another more static route (without a parameter), the |
.. and now it worked again. Seems there is an issue where |
I'm struggling with getting full offline support operational. The use case is full offline support after first load on a mobile device. The application runs as a single page app, but I'm using the automatic feature of react-cli that creates separate files for the routes in my app.
Specifically I'm struggling with what I actually have to do to get everything pre loaded the first time my app is loaded. My test case is loading the app, the going offline (flight mode) and trying to navigate to another screen.
Exactly how and where does preact-cli know which routes to pre-render (and pre-load / cache I guess)? I'm using
preact-cli-sw-precache
where I'm trying to set everything automatically with a configuration like:Is this enough for the build system to figure out all the routes (disregarding the details about how this gets set up in
preact.config.js
, or do I need to specify a list or urls in theprerender-urls.json
file in addition? And if so, how can I specify routes with "url based parameters", likelogid
in:My gut feeling says only one of these should be necessary, but I can't get it working, so any help would be appreciated.
The text was updated successfully, but these errors were encountered: