Enable serviceworker-webpack-plugin for your create-react-app project.
npm i -D rescript-service-worker-loader
Set up rescript as how its document said, then add 'service-worker-loader'
to the list, for example in my .rescriptsrc.js
:
const path = require('path');
module.exports = [
['use-babel-config', '.babelrc'],
['use-eslint-config', '.eslintrc'],
'disable-eslint',
[
'service-worker-loader',
{
entry: path.join(__dirname, 'src/IPFSServiceWorkerGateway/index.js'),
publicPath: process.env.NODE_ENV === 'development' ? '/' : '/ipfs-browser-gateway/',
},
],
];