From d1f0ae690eaf101274866b3f03653c1e3df50cfb Mon Sep 17 00:00:00 2001 From: hupe1980 Date: Fri, 17 May 2019 12:36:05 +0200 Subject: [PATCH] fix(gatsby-plugin-offline): Drop preload link for json from offline shell (#13935) --- .../gatsby-plugin-offline/src/gatsby-ssr.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 packages/gatsby-plugin-offline/src/gatsby-ssr.js diff --git a/packages/gatsby-plugin-offline/src/gatsby-ssr.js b/packages/gatsby-plugin-offline/src/gatsby-ssr.js new file mode 100644 index 0000000000000..0272af166ae8d --- /dev/null +++ b/packages/gatsby-plugin-offline/src/gatsby-ssr.js @@ -0,0 +1,21 @@ +export const onPreRenderHTML = ({ + getHeadComponents, + pathname, + replaceHeadComponents, +}) => { + if (pathname !== `/offline-plugin-app-shell-fallback/`) return + + const headComponents = getHeadComponents() + + const filteredHeadComponents = headComponents.filter( + ({ type, props }) => + !( + type === `link` && + props.as === `fetch` && + props.rel === `preload` && + props.href.startsWith(`/static/d/`) + ) + ) + + replaceHeadComponents(filteredHeadComponents) +}