Skip to content

Commit f8b7317

Browse files
authored
fix(gatsby-plugin-offline): Run app-shell.js from user cache directory for pnp compatibility (#22351)
* use user cache dir for app-shell.js * use fs.copyFileSync
1 parent 30b656a commit f8b7317

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/gatsby-plugin-offline/src/gatsby-node.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@ const _ = require(`lodash`)
88

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

11-
exports.createPages = ({ actions }) => {
11+
exports.onPreBootstrap = ({ cache }) => {
12+
const appShellSourcePath = path.join(__dirname, `app-shell.js`)
13+
const appShellTargetPath = path.join(cache.directory, `app-shell.js`)
14+
fs.copyFileSync(appShellSourcePath, appShellTargetPath)
15+
}
16+
17+
exports.createPages = ({ actions, cache }) => {
18+
const appShellPath = path.join(cache.directory, `app-shell.js`)
1219
if (process.env.NODE_ENV === `production`) {
1320
const { createPage } = actions
1421
createPage({
1522
path: `/offline-plugin-app-shell-fallback/`,
16-
component: slash(path.resolve(`${__dirname}/app-shell.js`)),
23+
component: slash(appShellPath),
1724
})
1825
}
1926
}

0 commit comments

Comments
 (0)