Skip to content

Commit

Permalink
fix(gatsby-plugin-offline): Run app-shell.js from user cache director…
Browse files Browse the repository at this point in the history
…y for pnp compatibility (#22351)

* use user cache dir for app-shell.js

* use fs.copyFileSync
  • Loading branch information
Js-Brecht committed Mar 17, 2020
1 parent 30b656a commit f8b7317
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/gatsby-plugin-offline/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ const _ = require(`lodash`)

let getResourcesFromHTML = require(`./get-resources-from-html`)

exports.createPages = ({ actions }) => {
exports.onPreBootstrap = ({ cache }) => {
const appShellSourcePath = path.join(__dirname, `app-shell.js`)
const appShellTargetPath = path.join(cache.directory, `app-shell.js`)
fs.copyFileSync(appShellSourcePath, appShellTargetPath)
}

exports.createPages = ({ actions, cache }) => {
const appShellPath = path.join(cache.directory, `app-shell.js`)
if (process.env.NODE_ENV === `production`) {
const { createPage } = actions
createPage({
path: `/offline-plugin-app-shell-fallback/`,
component: slash(path.resolve(`${__dirname}/app-shell.js`)),
component: slash(appShellPath),
})
}
}
Expand Down

0 comments on commit f8b7317

Please sign in to comment.