create-react-app的服务工作者不会忽略网址

时间:2018-05-13 02:15:16

标签: service-worker create-react-app sw-precache

我已经阅读了一堆关于create-react-app的文档/问题,并试图让我的服务工作者不提供特定网址。

根据create-react-app

的弹出版本中的评论
new SWPrecacheWebpackPlugin({
  // By default, a cache-busting query parameter is appended to requests
  // used to populate the caches, to ensure the responses are fresh.
  // If a URL is already hashed by Webpack, then there is no concern
  // about it being stale, and the cache-busting can be skipped.
  dontCacheBustUrlsMatching: /\.\w{8}\./,
  filename: "service-worker.js",
  logger(message) {
    if (message.indexOf("Total precache size is") === 0) {
      // This message occurs for every build and is a bit too noisy.
      return;
    }
    if (message.indexOf("Skipping static resource") === 0) {
      // This message obscures real errors so we ignore it.
      // https://github.com/facebookincubator/create-react-app/issues/2612
      return;
    }
    console.log(message);
  },
  minify: true,
  // For unknown URLs, fallback to the index page
  navigateFallback: publicUrl + "/index.html",
  **// Ignores URLs starting from /__ (useful for Firebase):
  // https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219**
  navigateFallbackWhitelist: [/^(?!\/__).*/, /^(?!\/que).*/],
  // Don't precache sourcemaps (they're large) and build asset manifest:
  staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/]
}),

特别是这个

  

//忽略从/ __开始的网址(对Firebase有用):         // https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219

然而,当我点击localhost:3000/__, or localhost:3000/__auth or localhost:3000/__que

他们所有人仍然打我的index.html。

如何让服务工作者忽略网址?

0 个答案:

没有答案