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

Add other file types in globPatterns #31

Closed andredarcie closed 3 years ago

andredarcie commented 3 years ago

How to add other types of files to globPatterns and change the default behavior?

Today the default cofiguration only supports this file types, how to chance and add sounds files like .wav and .mp3 globPatterns: ["**/*.{html,js,css,jpg,png}"],

mischnic commented 3 years ago

Specifying them in the cache object in package.json should work

{
    "dependencies": {
        // ...
    },
    //...
    "cache": {
        "swDest": "service-worker.js",
        "globPatterns": ["**/*.{html,js,css,jpg,png,wav.mp3}"]
    }
    //...
}
andredarcie commented 3 years ago

I added it to the package.json file and now it works! Thank you!

  "cache": {
    "disablePlugin": false,
    "inDev": true,
    "strategy": "default",
    "importWorkboxFrom": "local",
    "globPatterns": [
      "**/*.{html,js,css,jpg,png,wav,mp3,mpeg,ttf}"
    ]
  },

image