我有一个 Webpack 配置文件,它使用webpack-pwa-manifest
插件 ( https://github.com/arthurbergmz/webpack-pwa-manifest ) 生成 PWA 清单文件。清单文件名为manifest.hash.json
,其中“hash”是每次构建时动态生成的值。
我还使用(https://developers.google.com/web/tools/workbox/modules/workbox-webpack-pluginInjectManifest
)的插件来呈现预缓存清单,然后将其注入到服务工作者文件中。Workbox
这是我的 Webpack 配置文件的“插件”部分:
plugins: [
new CleanWebpackPlugin([ path.join(destDir, '*.*') ], {
allowExternal: true,
exclude: [],
verbose: true,
dry: false
}),
new MiniCssExtractPlugin({
filename: 'style.[hash].css'
}),
new VueLoaderPlugin(),
new HtmlWebpackPlugin({
template: path.join(projectRoot, 'src/index.html')
}),
new WebpackPwaManifest({
name: 'Test PWA',
short_name: 'Test PWA',
fingerprints: true,
inject: true,
lang: 'en-US',
start_url: 'https://localhost:8120/index.html',
display: 'standalone',
theme_color: '#777777',
background_color: '#333333',
icons: [
{
src: path.join(sourceDir, 'images/icon.png'),
sizes: [36, 48, 72, 96, 144, 192, 512],
destination: 'icons'
}
]
}),
new InjectManifest({
swSrc: path.join(projectRoot, 'src/sw.js'),
swDest: 'sw.js',
importWorkboxFrom: 'local',
globPatterns: ['dist/*.{json,js,html}']
})
]
问题是我找不到将渲染添加manifest.hash.json
到 InjectManifest 生成的预缓存清单中的方法。有什么办法可以让他们一起玩得很好,还是不可能?