-
Notifications
You must be signed in to change notification settings - Fork 20
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
support service worker / pwa's #46
Comments
we also added // deploy.js
s3: {
filePattern: '**/*.{js,css,png,gif,ico,jpg,xml,txt,svg,swf,eot,ttf,woff,woff2,otf,webmanifest}'
}, |
Thanks @jamemackson So it seems to me there's no changes needs to ember-cli-deploy per se. But maybe this is more of an educational thing that we need to include in the docs around best practices for deploying service workers. |
luke had asked i share my experience in getting this working so that it might be supported out of the box. at minimum some documentation would be great 👍 |
Thanks for your advice, i just followed them and came with this, just in case someone needs it // GET ServiceWorkers JS asset
app.get('/sw.js', (req, res, next) => {
debug('getting service workers file');
return redisClient.getAsync(`${APP_NAME}:sw:current-content`)
.then((index) => {
if (!index) {
res.status(404);
return res.type('txt').send('Not found');
}
res.type('js');
return res.send(index);
})
.catch(next);
}); |
I've had success with having the lightning server simply forward the request to the CDN so that the service worker file is uploaded as an asset like anything else. No need to host in Redis. |
follow up to conversation with @lukemelia on slack...
so to get the service worker working with the lightning approach here’s what we had to do:
app-name:{index|sw}:current-content
We then had to update our ember-lightning server to detect requests for sw.js and to respond with the appropriate content where it was always responding with the index.html content previously for any request of a given domain.
One thing to note is that supporting the ref based preview url isn’t practical here for the service worker itself as we’d need to modify the path embedded in the index file to request this specific version of the service worker. This is certainly possible but isn’t anything that we tackled for now.
The text was updated successfully, but these errors were encountered: