Custom Rules should come after generated rules
tacman opened this issue Β· comments
Version(s) affected
1.1.x
Description
Until I can figure out how to map rules to the pwa.yaml, I'm just adding them as custom rules. These come from the PWA-IndexedDB tutorial, their sw.js is at https://github.com/paritoshtripathi/PWA-Sample-IndexedDB/blob/master/solution/app/sw.js
and I'm trying to re-create the application without custom javascript.
workbox.precaching.precacheAndRoute([]);
const showNotification = () => {
self.registration.showNotification('Background sync success!', {
body: 'π`π`π`'
});
};
const bgSyncPlugin = new workbox.backgroundSync.Plugin(
'dashboardr-queue',
{
callbacks: {
queueDidReplay: showNotification
// other types of callbacks could go here
}
}
);
const networkWithBackgroundSync = new workbox.strategies.NetworkOnly({
plugins: [bgSyncPlugin],
});
workbox.routing.registerRoute(
/\/api\/add/,
networkWithBackgroundSync,
'POST'
);
How to reproduce
Add the above the sw.js.
The problem is that my rules come at the top of the js file, before all the assetmapper files have been loaded.
Possible Solution
Generate from yaml first, then custom rules?
Or re-add the placeholders like version 1.0 had
Additional Context
No response
Seems legit to me.
This will be fixed.
Note that do not want to go back to placeholders. It is possible to use priority to allow rules to be on top or at the end of the file (for services only).
It is possible to use priority to allow rules to be on top or at the end of the file (for services only).
Can you provide an example of user-defined (application-level) services? Maybe that's where I can hook in my pre-cached routes.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.