Vue PWA workboxOptions exclude folder structure

1.7k Views Asked by At

I have the following vue.config.js (showing just the relevant part)

pwa: {
    workboxPluginMode: 'InjectManifest',
    workboxOptions: {
      swSrc: 'src/plugins/service-worker/service-worker.js',
      exclude: [/.*images\/(?!cached).*/g, /\.map$/, /manifest\.json$/]
    }
  },

I'm looking to exclude all ./src/assets/images/* images unless they are in the following directory:

./src/assets/images/cached/*

Here is an example of this regex working: https://regex101.com/r/vANnrn/1/

However webpack/workbox still includes all of my images that might be included in components in the precache-manifest file.

My suspicion is that the exclude option applies to the folder structure of assets inside /dist rather than /src? If that's the case this won't work because webpack puts all images into a flat /dist/img folder.

0

There are 0 best solutions below