Webpack Workbox插件3.0-缓存其他文件(非Webpack资产)

时间:2018-07-23 11:01:28

标签: reactjs webpack service worker workbox

webpack-plugin注册服务工作者。

new CopyWebpackPlugin([
  { from: './src/manifest.json', to: '' },
  { from: './src/assets/homescreen', to: 'assets/homescreen/' }
]),
new WorkboxPlugin.GenerateSW({
  clientsClaim: true,
  skipWaiting: true
}),

我的问题是precache-manifets.js文件中未包含manifest.json。因此,问题是-如何使用workbox-webpack-plugin缓存其他文件?

1 个答案:

答案 0 :(得分:0)

默认情况下,/^manifest.*\.js(?:on)?$/显然在工作区3中是排除的。

它已在Workbox v4.0.0-alpha.0中修复。获取新版本或尝试以下技巧:

    new InjectManifest({
        // some other options...
        exclude: [] // <-- Add this
      })

您可能会发现这很有趣: https://github.com/GoogleChrome/workbox/pull/1679