mischnic / parcel-plugin-sw-cache

📦👷 Parcel plugin for caching using a service worker
https://npm.im/parcel-plugin-sw-cache
MIT License
47 stars 6 forks source link

Unable to resolve path for swDest. #10

Closed dsych closed 6 years ago

dsych commented 6 years ago

The swDest property of the config gets carried over between builds which means when we directly modify swDest from config here, the subsequent rebuild is going to fail since config.swDest already contains the old resolved path and we are adding additional path config.swDest. We end up with something like: '/pathToYourFile/file/pathToYourFile/file'

We can fix this by changing this line to

config.swDest = path.resolve(outDir, config.swDest);
dsych commented 6 years ago

While we are still on swDest topic, I find it useful to have an option that allows you to turn off the resolve. The reason why you would want to do that is to trick workbox into thinking that swSrc and swDest are different files by providing relative path for swDest. This could be used to inject precached routes into the processed SW which contains a bunch of imports.