How to modify auto generated service-worker in Create-React-App

一笑奈何 提交于 2019-11-29 06:52:46

We had a similar problem while working on a project recently and we didn't want to "eject". We created a little tool that allows you to append custom service worker code to the one generated by CRA.

Have a look here: https://github.com/bbhlondon/cra-append-sw

You would can run npm run eject and get access to the underlying Webpack configuration.

Once you do that, the webpack.config.prod.js file can be modified to adjust your generated service worker. Look for the section that configures SWPrecacheWebpackPlugin.

You can add in an additional runtimeCaching configuration option to that section to accommodate your runtime caching needs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!