craco-workbox
Advanced tools
Comparing version
@@ -12,6 +12,10 @@ const path = require("path"); | ||
webpackConfig.plugins.forEach(plugin => { | ||
webpackConfig.plugins.forEach((plugin) => { | ||
if (plugin.constructor.name === "GenerateSW") { | ||
plugin.config = workboxConfig(plugin.config); | ||
plugin.config = workboxConfig.GenerateSW(plugin.config); | ||
} | ||
if (plugin.constructor.name === "InjectManifest") { | ||
plugin.config = workboxConfig.InjectManifest(plugin.config); | ||
} | ||
}); | ||
@@ -27,3 +31,3 @@ } catch (error) { | ||
return webpackConfig; | ||
} | ||
}, | ||
}; |
{ | ||
"name": "craco-workbox", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "A simple craco plugin to override the workbox config in CRA2", | ||
@@ -15,8 +15,8 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"eslint": "^5.13.0", | ||
"eslint-config-prettier": "^4.0.0", | ||
"eslint-plugin-prettier": "^3.0.1", | ||
"husky": "^1.3.1", | ||
"lint-staged": "^8.1.3", | ||
"prettier": "^1.16.4" | ||
"eslint": "^8.0.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"husky": "^7.0.2", | ||
"lint-staged": "^11.2.3", | ||
"prettier": "^2.4.1" | ||
}, | ||
@@ -34,6 +34,3 @@ "lint-staged": { | ||
} | ||
}, | ||
"dependencies": { | ||
"dot-json": "^1.1.0" | ||
} | ||
} |
@@ -21,3 +21,5 @@ # craco-workbox | ||
``` | ||
```javascript | ||
// craco.config.js | ||
const CracoWorkboxPlugin = require('craco-workbox'); | ||
@@ -34,6 +36,16 @@ | ||
``` | ||
module.exports = options => { | ||
options.skipWaiting = true; | ||
return options; | ||
```javascript | ||
// workbox.config.js | ||
module.exports = { | ||
GenerateSW: options => { | ||
// override GenerateSW config here | ||
// e.g. options.skipWaiting = true; | ||
return options; | ||
}, | ||
InjectManifest: options => { | ||
// override InjectManifest config here | ||
// e.g. options.maximumFileSizeToCacheInBytes = 10 * 1024 * 1024; | ||
return options; | ||
} | ||
}; | ||
@@ -40,0 +52,0 @@ ``` |
0
-100%35
9.38%55
27.91%6252
-93.28%- Removed
- Removed
- Removed
- Removed
- Removed
- Removed