exclude does not work correctly
Brought to you by:
tomkozak
Originally created by: aprilmintacpineda
Library Affected:
workbox-sw, workbox-build, etc.
Browser & Platform:
all browsers
According to the docs:
This allows you to specifically omit assets matching any of the provided criteria from being included in the precache manifest. It provides a filename-based approach to filtering.
exclude: [
/main.(?:.*?).css$/gim,
/\.map$/gim,
/manifest.*\.js(?:on)?$/gim,
/icon_.*.png/gim
]
resulting precache manifest:
self.__precacheManifest = [
{
"url": "/static/js/main.8acd832abdad30f2360c.js"
},
{
"url": "/static/js/runtime.8acd832abdad30f2360c.js"
},
{
"revision": "545cb59b4526ecbf2e3921d126a68c03",
"url": "/static/index.html"
},
{
"revision": "472b65ed38ed9e0c7830923d23a5644b",
"url": "/static/favicon.ico"
},
{
"revision": "3e55c1cea767df1fb708d5fdd28c53b9",
"url": "/static/favicon.png"
},
{
"revision": "02828d2baf4148969294dc8e18d18958",
"url": "/static/icons/icon_24x24.png"
},
{
"revision": "2feeb8718a1653ec48136415840610fb",
"url": "/static/icons/icon_256x256.png"
},
{
"revision": "36025a4911dc4ee6205f40a9fb921148",
"url": "/static/icons/icon_512x512.png"
}
];
I was expecting ALL files that has icon_ in the file name to not be included. It managed to remove ONLY SOME but not all.
Here's the catch:
After making changes, webpack updates the precache file resulting to this:
self.__precacheManifest = [
{
"url": "/static/js/main.9039b0aceb45eff07d28.js"
},
{
"url": "/static/js/runtime.9039b0aceb45eff07d28.js"
},
{
"revision": "94234b2318acfc82f1306f773bd9c94e",
"url": "/static/index.html"
}
];
Now the icons regex worked, BUT notice the favicon png and ico are missing. Their file name does not match the regex, right?
Originally posted by: philipwalton
@aprilmintacpineda you say this, but then you don't mention what the changes where, can you elaborate?
@jeffposnick any idea why their
icon_regex wouldn't be working here?Originally posted by: aprilmintacpineda
Changes to any file that's preloaded. I'm running webpack on watch, it detects the main file changed, the precache-file changes as well, the service worker changes as well because the hashes has changed.
Originally posted by: jeffposnick
How are the
/icons/assets included as part of your webpack build? Are they referenced via a loader, are the included viacopy-webpack-plugin, or something else?If you could share the part of your webpack config that end up pulling in those icon assets, that would be useful.
Originally posted by: sprlwrksAprilmintacpineda
I use https://github.com/webpack-contrib/copy-webpack-plugin to copy the whole
public/directory tobuild/.Originally posted by: jeffposnick
And is
copy-webpack-pluginlisted before or afterworkbox-webpack-plugin? Could you share thepluginssection of your webpack config?Originally posted by: jeffposnick
I believe this is a duplicate of [#1790].
Related
Tickets:
#1790Ticket changed by: jeffposnick