Create-react-app: CRA 4 does not generate service-worker on build

Created on 6 Nov 2020  路  1Comment  路  Source: facebook/create-react-app

After updating react-scripts to version 4 I don't have any more service worker in the build directory.

Manifest is still there

image

bug report needs triage

Most helpful comment

Okay, I figured out that there is a change regarding this.

https://create-react-app.dev/docs/making-a-progressive-web-app/

Since CRA 4 the service worker is opt-in, so if someon want to update from older versions, need to create by himself service worker.

The easyest way is like this:

1 Create somewhere on your computer a new CRA with the service worker template:

npx create-react-app my-app --template cra-template-pwa

2 Copy the service-worker.js from the new created app into your src directory

3 Copy the "workbox-*" dependencies from the package.json into your package.json dependencies

4 (Optional) If you want web-vitals, copy the web-vitals dependency from package.json into your package.json

and don't forget to run again 'yarn install' or 'npm install'

Thats it

>All comments

Okay, I figured out that there is a change regarding this.

https://create-react-app.dev/docs/making-a-progressive-web-app/

Since CRA 4 the service worker is opt-in, so if someon want to update from older versions, need to create by himself service worker.

The easyest way is like this:

1 Create somewhere on your computer a new CRA with the service worker template:

npx create-react-app my-app --template cra-template-pwa

2 Copy the service-worker.js from the new created app into your src directory

3 Copy the "workbox-*" dependencies from the package.json into your package.json dependencies

4 (Optional) If you want web-vitals, copy the web-vitals dependency from package.json into your package.json

and don't forget to run again 'yarn install' or 'npm install'

Thats it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

onelson picture onelson  路  3Comments

fson picture fson  路  3Comments

Evan-GK picture Evan-GK  路  3Comments

barcher picture barcher  路  3Comments

alleroux picture alleroux  路  3Comments