stereobooster / react-snap

👻 Zero-configuration framework-agnostic static prerendering for SPAs
MIT License
5.04k stars 391 forks source link

sw-precache is deprecated #483

Open Cooya opened 3 years ago

Cooya commented 3 years ago

As sw-precache is now deprecated, I would suggest to update the doc here with workbox-cli. For instance :

package.json

"scripts": {
    "build-snap": "react-scripts build && react-snap && workbox generateSW scripts/workbox-config.js
}

scripts/workbox-config.js

module.exports = {
    globDirectory: 'build/',
    globPatterns: ['**/*.{html,json,js,css,txt}'],
    swDest: 'build/service-worker.js',
    sourcemap: false
};

I knew nothing about both of them and I had to spend some time to understand how to generate a custom service worker for SSR. I think it would be great to show this already figured out configuration in the doc for other beginners like me :blush: