Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !8485

Add support to customize the Service Worker with InjectManifest and Workbox v5

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/marlonmleite/master into master Feb 14, 2020
  • Overview 17
  • Commits 19
  • Pipelines 0
  • Changes 11

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/

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/marlonmleite/master