Created
June 13, 2018 12:23
-
-
Save laruiss/77438b183729938484ecc51a40c11a4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: [/^(?!\/__).*/], | |
// Don't precache sourcemaps (they're large) and build asset manifest: | |
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/], | |
runtimeCaching: [{ | |
urlPattern: /\/api\//, | |
handler: 'fastest', | |
options: { | |
cache: { | |
maxEntries: 20, | |
name: 'api-cache' | |
} | |
} | |
}] | |
}), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment