I'm deploying to Github pages which means I'm not able to deploy to the root of the server. It seems that the templates and build scripts assume that apps will deployed in the root. I sent a PR for app-drawer-template (https://github.com/Polymer/app-drawer-template/pull/22), but even with those changes in place I was having issues getting the service worker to pre-cache resources.
Even though I removed the leading slashes from paths in sw-precache-config.js, the generated service-worker.js has them added back. I had to go in and modifiy the service worker in the build directory before deploying to get things working as expected.
We are currently working on a project to make build more customizable. I believe this functionality will be added through that interface once it is built.
pinging @justinfagnani to make sure he's aware of this.
For the moment I'va found a workaround to make that path relative. In the sw-precache-config.js I add:
stripPrefix: '',
replacePrefix: '.',
And it adds a . before the slash.
Here my complete sw-precache-config.js file:
module.exports = {
staticFileGlobs: [
'/index.html',
'/manifest.json',
'/bower_components/webcomponentsjs/webcomponents-lite.min.js'
],
stripPrefix: '',
replacePrefix: '.',
navigateFallback: 'index.html',
navigateFallbackWhitelist: [/^(?!.*\.html$|\/data\/).*/]
};
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
For the moment I'va found a workaround to make that path relative. In the
sw-precache-config.jsI add:And it adds a
.before the slash.Here my complete
sw-precache-config.jsfile: