-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
π PWA support #301
Comments
The name "scrambling" is a problem when working with service workers as well. if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('./service-worker.js')
.then(function(registration) {
console.log('Registration successful, scope is:', registration.scope);
})
.catch(function(error) {
console.log('Service worker registration failed, error:', error);
});
} |
Given the control and information parcel has about the app it's working on, might be the perfect opportunity for parcel to generate a service worker for us. IMO, it would be an opinionated feature to add but one that would be great. All apps could benefit from using a serviceworker. Parcel just happens to have the perfect opportunity to generate one. |
@kennetpostigo When you say |
@Olian04 well seeing as it knows the assets a site uses, it could cache assets for us automagically. |
@kennetpostigo Yes that is true, however caching responses is only one part of a service worker. And since we can't register multiple service workers for the same site the caching should probably be left to the programmer. |
@Olian04 sure, but at the very least, if there is no service worker file present for this, parcel could fallback to generating a basic one for you to cache assets at the very least. Some plugins parcel might take inspiration from and "turn on by default" when parcel detects you don't have a dedicated serviceworker could be: |
@kennetpostigo at first I was ready to agree with you, since on the surface providing a service worker automatically would just improve performance. However, after reasoning about it I don't actually think we want to automatically force a service worker onto everyone who uses parcel. We have no way of knowing what issues that might cause. On top of that, I don't really think it's parcels place to be injecting code into a prod app. Parcel is first and foremost a bundler, and it isn't really common practice for bundlers to add functionality to the bundle without the users consent. I like the idea of parcel offering a cache only service worker as an option for the dev to opt into though. |
It could be opt-in |
As of #398, parcel detects calls to |
I have create a plugin (https:/mischnic/parcel-plugin-sw-cache) which should act similiar to the sw-precache webpack plugin (although using the still in development successor workbox). But I ran into a few 'architectural' problems:
|
I also made a plugin. https:/cyyyu/parcel-plugin-sw-precache π |
I went the way with workbox cli instead, it seems to work alright for me. |
@marcusasplund With the next release, this will be handled automatically. |
@mischnic I suppose this commit should take care of the problem, or am i mistaken? <link rel="apple-touch-icon" sizes="180x180" href="/dist/1c7c3abdf60685a811043556b00ed1bf.png">
<link rel="icon" type="image/png" sizes="32x32" href="/dist/e78f1c521d44f72702ec4666af75cbab.png">
<link rel="icon" type="image/png" sizes="16x16" href="/dist/5d284f8fd4e08e364e1ce496e68e22a2.png">
<link rel="manifest" href="/dist/54dce0fdf0c5f40eef2cab9e124ae808.webmanifest">
<link rel="mask-icon" href="/dist/a76e301e687fd68bb19bdfe8f15ff16a.svg" color="#5bbad5"> Is this still expected behavior or have i missed something? |
@marcusasplund this is expected behaviour currently. There is an open RFC for naming strategy however, feel free to add to that issue :) Sent with GitHawk |
Hey guys, how are things going with PWA support? |
I'm interested too, how is it progressing? |
Hey, still no PWA? :( Sadly I'll have to move to Rollup instead of Parcel just because of not having PWA suppprt. |
Edit: not trying to assume too much, since it was a rather leading intro |
My problem is that webmanifest doesn't work properly. I mean, it doesn't work at all. Icons / themes are not set on mobile version. Here is the repo And webmanifest: {
"name": "V ! R T L",
"short_name": "V ! R T L",
"description": "V ! R T L's personal site",
"theme_color": "#000000",
"background_color": "#ffffff",
"display": "standalone",
"scope": ".",
"dir": "ltr",
"lang": "en-US",
"start_url": "./index.html",
"icons": [
{
"src": "assets/manifest/icon-72x72.png",
"sizes": "72x72",
"type": "image/png"
},
{
"src": "assets/manifest/icon-96x96.png",
"sizes": "96x96",
"type": "image/png"
},
{
"src": "assets/manifest/icon-128x128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "assets/manifest/icon-144x144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "assets/manifest/icon-152x152.png",
"sizes": "152x152",
"type": "image/png"
},
{
"src": "assets/manifest/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "assets/manifest/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "assets/manifest/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"splash_pages": null
} For reproduce you need to run |
@talentlessguy The link to your web manifest doesnβt resolve for me; also your repo source looks to make use of poi and I donβt see parcel as a dependency in your |
Oh sorry I forgot to attach links to history. Here is the version with Parcel. |
@talentlessguy the only major difference I noticed was in your index.html, the meta tag ref was the raw manifest file name, while mine use the path relative notation, such as Hereβs my manifest link, if you want to try to play βspot the differencesβ. |
@edm00se it is weird that this works |
For those of you asking for "PWA support", what are you referring to exactly? We already support webmanifest files, and there are various plugins in this thread that will generate a service worker for you if you don't want to write it yourself. So, what else are you looking for Parcel to do for you? |
@devongovett see my comment above, manifest link doesn't work without "raw" path. But I think |
What exists today works for me, so with that caveat:
While the lazy developer in me would love to see native support of generating the web manifest or service worker, the plugin space is probably the best realm for that. Neither above plugin worked (immediately) for me when I tried them, so I moved on; this was months ago, so they may be just fine. I generate my service worker from workbox, after the build Parcel completes, which is what's driving my above scenario. Also, thank you @devongovett. |
Related: #2080 |
This is both a question and a πββοΈ feature request.
Question:
Since a PWA requires a set of resources to exists along side its
manifest.webmanifest
file. My question is, is there a way to include a file without having its name "scrambled"? This would apply to both the manifest file and its resources. (Related to #280)Feature request:
It would be nice to have parcel look through the manifest file for files to include in the build.
For example (partial files):
Should result in both
manifest.webmanifest
as well aspwa/icons/48.png
andpwa/icons/72.png
being included in the build.The text was updated successfully, but these errors were encountered: