Created by: marlonmleite
Description
This PR originated from discussion #7966 and many issues related to Service Workers and customizations in the CRA to configure the Workbox plugin over the past last year.
With this feature after compiling the Service Worker, the compiled features are identical to the existing one. The conversion of the existing functionalities in GenerateSW to InjectManifest was carried out, respecting all existing standard configurations currently.
Why Workbox v5?
We have also taken advantage of the momentum and migrated to v5.0.0 from the Workbox, because for build the service worker with webpack, environment variables and more are only available in v5. See more.
What features?
Now, it will be possible to make any customized configuration in the Service Worker and thus make it possible to use several functionalities at the service worker level: https://github.com/facebook/create-react-app/issues/7966#issuecomment-579442388
Migrate
To update your current react-scripts to this new version, this not contain a break change. To use the configuration using InjectManifest you will need to create the sw-template.js or sw-template.ts file in your application's src/ directory.
Local test
Checkout in this branch, run the installation and bootstrap scripts and run the commands:
with cra-template:
yarn create-react-app ../sw-app --template file:./packages/cra-template
with cra-template-typescript:
yarn create-react-app ../sw-app --template file:./packages/cra-template-typescript
Live app
This is a real application created from this new functionality, it already has the service worker enabled. Look: https://test-cra-97e59.firebaseapp.com/