-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
feat(html): add head when missing from entry point #784
base: main
Are you sure you want to change the base?
feat(html): add head when missing from entry point #784
Conversation
✅ Deploy Preview for vite-plugin-pwa-legacy ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
commit: |
console.warn([ | ||
'', | ||
yellow('PWA WARNING:'), | ||
'</head> and <body> not found in the html, the service worker and web manifest will not be injected.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace this message with:
</head> and <body> not found in the html, the service worker and the web manifest may not be injected.
@@ -25,20 +26,36 @@ navigator.serviceWorker.register('${path}', { scope: '${options.scope}' }) | |||
}`.replace(/\n/g, '') | |||
} | |||
|
|||
export function checkForHtmlHead(html: string) { | |||
if (!html.includes('</head>')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we also check for <head />
? This will require to parse the html: Vite doesn't add the entries if head
is missing and returning the tag array instead here
Description
When there is no
head
in the html entry point, the sw and the web manifest may not be register: this PR checks for</head>
and<body>
to add the head when required, showing a warning when missing both.Linked Issues
resolves #782
Additional Context
Tip
The author of this PR can publish a preview release by commenting
/publish
below.