Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

add service-worker-index.html #525

Merged
merged 1 commit into from
Feb 1, 2019

Conversation

nolanlawson
Copy link
Contributor

This fixes #422 by outputting a new /service-worker-index.html file which can be cached by the service worker and served in offline use cases.

The reason I went with service-worker-index.html rather than the old index.html is that the latter breaks sapper export, since the service worker-targeted index.html conflicts with the base route. Since index.html is kind of an imprecise name for it anyway, I figured renaming to service-worker-index.html made the most sense.

The only change that users will have to make in order to get this to work is to use the commented code from sapper-template defined here. We'll probably want to update that commented code anyway, since it hasn't worked for about a year.

I have tested this with sapper-template and it works.

To test, you just npm link this PR to sapper-template, then in sapper-template, do npm run build && npm start and then navigate to the base URL, then put the Dev Tools in offline mode, uncomment the commented-out service worker code, then refresh. At this point, the new page should be served by the service worker using service-worker-index.html.

@nolanlawson
Copy link
Contributor Author

This PR will fail in CI until #521 is merged.

@Conduitry
Copy link
Member

Re-ran Travis build (the failing test looks like probably just some flakiness). I don't see how to and/or I don't have the permissions to re-run the Appveyor build.

@nolanlawson
Copy link
Contributor Author

Rebased

@nolanlawson
Copy link
Contributor Author

Side note: I am now running this in Pinafore unstable, at https://dev.pinafore.social. Been testing manually and so far everything seems to be working as before. 🙂

To be fair, though, Pinafore does not do anything fancy like preloading or server routes.

@nolanlawson
Copy link
Contributor Author

Hmm, the prefetches programmatically test seems to be failing.

@nolanlawson
Copy link
Contributor Author

nolanlawson commented Dec 11, 2018

I cannot reproduce the prefetches programmatically test failure locally. I'm using Ubuntu...

@Conduitry
Copy link
Member

Take a look at #531 - if you haven't rebased on master since that was merged, give that a go.

@nolanlawson
Copy link
Contributor Author

Rebased!

@nolanlawson
Copy link
Contributor Author

Tests are green. :)

@Rich-Harris Rich-Harris merged commit 79fa15d into sveltejs:master Feb 1, 2019
@Rich-Harris
Copy link
Member

released 0.24.3, finally. thank you!

nolanlawson added a commit to nolanlawson/sapper that referenced this pull request Feb 15, 2019
As far as I can tell, `/index.html` should no longer exist (outside of `sapper export`, which doesn't apply here). After sveltejs#525 was merged, we're now using `/service-worker-index.html`, but that's handled by `get_page_handler.ts`, not here. So this code is doing nothing.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shell "index.html" file is not created
3 participants