You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.
I ran into this same issue when trying to get setup via CLI and ended up fixing it by converting my config .json into a .js file using module.exports. This allowed the urlPattern field to use an actual RegExp rather than being forced to use a string.
Looking at the cli.js code it seems the file specified as a config is just brought in via require, making this possible.
Thanks for bringing this up. I was toying with the idea of looking at any strings that begin and end with / and implicitly converting them to RegExp objects, but the idea of just promoting JavaScript configuration via module.exports is really a better approach, and should be backwards compatible with people who pass in JSON.
As @mactookmyname mentions, there's no code change needed to the sw-precache command line interface to support this, but I'm going to update the documentation and sample external configuration file to make it clear that the module.exports approach is preferred to JSON.
My json config has the following:
which produces:
toolbox.router.get("/users\\.json/", toolbox.networkFirst, {"cache":{"name":"api"}});
It should produce the following, right?
toolbox.router.get(/users\.json/, toolbox.networkFirst, {"cache":{"name":"api"}});
The text was updated successfully, but these errors were encountered: