Comments (5)
To change this directly, you'd need access to the underlying webpack
configuration to do that, which is only possible with create-react-app
if you eject.
Alternatively, after the c-r-a
build process completes you could attempt to run an additional command that would rename the generated service worker file, but I'm not sure what the best way to automate that would be.
(Which libraries are you using that require a specific service worker name, by the way?)
from pwa.
(Which libraries are you using that require a specific service worker name, by the way?)
firebase FCM will automatically try to register a service worker with the name firebase-messaging-sw.js
. Trying to change the name after build should be doable with a bash script on a postbuild script. Thanks.
from pwa.
You can use FCM with an existing top-level service worker; I believe you need to call importScripts()
from that top-level service worker (like the one generated in c-r-a
) to pull in the FCM code, and then something with:
- https://firebase.google.com/docs/reference/js/firebase.messaging.Messaging#gettoken
- https://firebase.google.com/docs/cloud-messaging/js/receive#web-v8
to pass through the registration info? I'm not 100% sure of all the steps, but it is possible.
from pwa.
Yes, you can get the registration object and pass it down to the getToken method and it will use that service worker. However, that means that I will have to handle the registration and keep the correct reference somewhere.
While this is not very problematic but I am not using the PWA template, which means that I don't have the registration scripts and that stuff. But that is just the smallest problem, the main problem is that it is too early for my project to be cached by a service worker and all the problems that has. I want every release to reach all my users as soon as possible.
All I wanted from CRA was to compile my SW from typescript and bundle the proper imports into the file (i18n and some libs that I may need) without any caching, but seems that such thing is not possible.
I tried deactivating the caching according to docs and the generated SW is still huge, I don't understand what it includes.
from pwa.
You don't have to use the c-r-a
template for PWAs in that case. You can just create your own bare-bones service worker file containing whatever you want and... I am not actually sure how to tell c-r-a
to compile it, but that's more of a question for the c-r-a
project itself. But once you have the service worker compiled, it can be registered from your main web app via navigator.serviceWorker.register('my-sw.js')
.
Using this PWA template is optional, and intended for folks who do want that Workbox-based precaching, which does require deep integration with your underlying webpack
build.
from pwa.
Related Issues (20)
- Question: Useless dependencies HOT 2
- Error: Unexpected token '<' after publishing new version HOT 10
- Updating the new version HOT 2
- Enable debugging mode of Workbox HOT 2
- Service worker is deleted immediately after successful registration
- Open to PR for Create React App PWA offline fallback page only? HOT 3
- Upgrading Workbox to v6 and above HOT 4
- Network First for non-standalone apps HOT 2
- `checkValidServiceWorker()` currently doesn't cover the case where I forget to start local server
- Service worker doesn't work out of the box HOT 3
- cra-template-pwa-typescript gives a TS2322 error HOT 7
- Typescript version of serviceWorkerRegistration refers to Javascript file HOT 1
- GET http://localhost:3000/service-worker.js returns index.html when using npm start HOT 1
- Cache Refresh Issue at a time new Release HOT 1
- Missing JSDOC
- caniuse-lite is outdated.
- Dependencies are out of date
- React 18 ReactDom.render HOT 1
- Service worker is not picking new build JS/CSS files
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pwa.