Add PWA functionality#2758
Closed
Harjun751 wants to merge 6 commits intoMarkBind:masterfrom
Closed
Conversation
Let's, * Add a flag in CLI init command for PWA functionality * Add variables in Configs to indicate PWA requirements * Update page templates to include PWA injection code * Add basic assets required for PWAs
sw.js uses cache-first strategy. Service worker is installed on localhost scope while developing. This means that if building and running another website locally, the service worker can still return cached values from the previous website the dev was working on. Change to network-first strategy to mitigate this. Network-first hits the resource first and falls back to cache if request fails.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of this pull request?
Resolves #2640
Overview of changes:
--pwatomarkbind initto initialize a MarkBind website with basic PWA functionalitypwafield insite.jsonthat can be set to true. This makes it so that the required lines to install the PWA manifest and service worker is included in the built html files.Anything you'd like to highlight/discuss:

When using
markbind init --pwato initialize a site, the default PWA values are like so:It shows a dummy image and name.
I was thinking if it was possible to use the
site.jsonfile to include the configuration of the PWA manifest, so that it could be dynamically created every time. But then I thought that most likely the PWA manifest would only be edited once or a few times, so it wouldn't be worth implementing that.So the intended workflow is for users to simply update the manifest directly if there are any changes to things like the site name, base URL, etc. Let me know if this is reasonable!
Additionally, the current implementation only allows for one service worker in the root of the site. I think it would be possible to improve upon this by adding a list field to the
site.jsonthat would allow the listing of all intended service worker paths in the application. However, I do think that this is a relatively niche case considering that MarkBind is not interaction-heavy and for documentation etc. Also I'm rushing for the CS3281 application due date heehee.Testing instructions:
Further testing may be done by building the websites in
packages/cli/test/functional/**_pwaand ensuring that install prompts are displayed on supported browsers.Proposed commit message: (wrap lines at 72 characters)
Add PWA support
Checklist: ☑️
Reviewer checklist:
Indicate the SEMVER impact of the PR:
At the end of the review, please label the PR with the appropriate label:
r.Major,r.Minor,r.Patch.Breaking change release note preparation (if applicable):