From eb8db3cd97d8d97fafc82e841e23551d85aa3ccd Mon Sep 17 00:00:00 2001 From: Jan Gosmann Date: Tue, 12 May 2020 20:36:08 +0200 Subject: [PATCH] Dereference symlinks when copying to public path --- .../src/extend-file-node.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/gatsby-source-filesystem/src/extend-file-node.js b/packages/gatsby-source-filesystem/src/extend-file-node.js index e381393caaee9..20433275b8952 100644 --- a/packages/gatsby-source-filesystem/src/extend-file-node.js +++ b/packages/gatsby-source-filesystem/src/extend-file-node.js @@ -24,14 +24,19 @@ module.exports = ({ type, getNodeAndSavePathDependency, pathPrefix = `` }) => { ) if (!fs.existsSync(publicPath)) { - fs.copy(details.absolutePath, publicPath, err => { - if (err) { - console.error( - `error copying file from ${details.absolutePath} to ${publicPath}`, - err - ) + fs.copy( + details.absolutePath, + publicPath, + { dereference: true }, + err => { + if (err) { + console.error( + `error copying file from ${details.absolutePath} to ${publicPath}`, + err + ) + } } - }) + ) } return `${pathPrefix}/static/${fileName}`