Skip to content

Commit

Permalink
feat(DEV-13): create precache by creating a service-worker file and w…
Browse files Browse the repository at this point in the history
…orkbox
  • Loading branch information
hhimanshu committed Jul 7, 2021
1 parent 257128e commit 0040b2b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
Binary file removed mockup.png
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"@fontsource/poppins": "^4.4.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^5.2.0"
"react-router-dom": "^5.2.0",
"workbox-precaching": "^6.1.5"
}
}
3 changes: 3 additions & 0 deletions src/service-worker.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
import {precacheAndRoute} from 'workbox-precaching';

precacheAndRoute(self.__WB_MANIFEST)
console.log('Hello from service-worker.js');
5 changes: 4 additions & 1 deletion webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const WorkboxPlugin = require('workbox-webpack-plugin');
const { InjectManifest } = require('workbox-webpack-plugin');

module.exports = {
entry: {
Expand All @@ -20,6 +20,9 @@ module.exports = {
{ from: 'src/icons/manifest', to: './' },
],
}),
new InjectManifest({
swSrc: './src/service-worker.js'
})
],
output: {
filename: '[name].[contenthash].bundle.js',
Expand Down

0 comments on commit 0040b2b

Please sign in to comment.