Workbox: Precaching the generated WebpackPwaManifest manifest asset

Created on 26 Jul 2018  路  3Comments  路  Source: GoogleChrome/workbox

*workbox-webpack-plugin.^3.4.1

Browser & Platform:
chrome,"webpack": "^4.15.0",node v10.6.0,npm 6.1.0,ubuntu 16.04

i wish to add generated manifest.json to the SWprecache array .
copied/generated manifest.json does not get included in precache-manifest.js.
This is the config i am using in webpack config:
new WebpackPwaManifest({
name: 'TestApp',
short_name: 'TestApp',
description: 'Description!',
background_color: '#01579b',
theme_color: '#01579b',
'theme-color': '#01579b',
start_url: '/',
icons: [
{
src: path.resolve('src/assets/icons/icon.png'),
sizes: [96, 128,144,152,192, 256, 384, 512],
destination: path.join('assets', 'icons')
}
]
}),
new InjectManifest({
globDirectory: '.',
globPatterns: ['dist/manifest.*.json'],
swSrc: './src/sw-default.js',
swDest: './sw.js',

})

Tried with new CopyWebpackPlugin([{from:'./src/manifest.json',to:'./assets'},{from:'./src/assets/icons',to:'assets/icons'}]),
manifest.json is precached.
but with
new CopyWebpackPlugin([{from:'./src/manifest.json'},{from:'./src/assets/icons',to:'assets/icons'}]),
it does not work -InjectManifest plugin adds manifest.json if its in assets directory but not when its in the same build directory .

Is this an issue with the plugin or should i configure it differently?
-----------Edit: got manifest.json in to precache by providing the glob directory as src and patterns as .json. But i had to generate manifest.json in the source directory to get it in to precache manifest. Please let me know if this can be achieved through plugin .

Bug P2 workbox-webpack-plugin

Most helpful comment

It's a default config, not a bug? Took me a lot of time until I found this answer https://stackoverflow.com/a/52112483/2722212

Apparently exclude option excludes manifest by default with default value of [/\.map$/, /^manifest.*\.js(?:on)?$/]

Why is excluding manifest.json a reasonable default?

All 3 comments

I'm thinking that we might need to do something specific to pick up on the output of the WebpackPwaManifest in the list of assets that workbox-webpack-plugin knows about.

It's a default config, not a bug? Took me a lot of time until I found this answer https://stackoverflow.com/a/52112483/2722212

Apparently exclude option excludes manifest by default with default value of [/\.map$/, /^manifest.*\.js(?:on)?$/]

Why is excluding manifest.json a reasonable default?

It's fixed in v4.0.0-alpha.0 (#1679)

Was this page helpful?
0 / 5 - 0 ratings