From c54664bbe0d1f06b12b64e13c5ec61601f30597c Mon Sep 17 00:00:00 2001 From: "Cathy J. Fitzpatrick" Date: Sat, 2 Nov 2024 09:03:11 -0700 Subject: [PATCH] build(vite): fix assets directories with symlinks present (#3359) --- vite.config.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/vite.config.js b/vite.config.js index 4bfd66d2585..36397f4f6bd 100644 --- a/vite.config.js +++ b/vite.config.js @@ -20,13 +20,22 @@ if (process.env.SUNSHINE_BUILD_HOMEBREW) { console.log("Building for homebrew, using default paths") } else { + // If the paths supplied in the environment variables contain any symbolic links + // at any point in the series of directories, the entire build will fail with + // a cryptic error message like this: + // RollupError: The "fileName" or "name" properties of emitted chunks and assets + // must be strings that are neither absolute nor relative paths. + // To avoid this, we resolve the potential symlinks using `fs.realpathSync` before + // doing anything else with the paths. if (process.env.SUNSHINE_SOURCE_ASSETS_DIR) { - console.log("Using srcdir from Cmake: " + resolve(process.env.SUNSHINE_SOURCE_ASSETS_DIR,"common/assets/web")); - assetsSrcPath = resolve(process.env.SUNSHINE_SOURCE_ASSETS_DIR,"common/assets/web") + let path = resolve(fs.realpathSync(process.env.SUNSHINE_SOURCE_ASSETS_DIR), "common/assets/web"); + console.log("Using srcdir from Cmake: " + path); + assetsSrcPath = path; } if (process.env.SUNSHINE_ASSETS_DIR) { - console.log("Using destdir from Cmake: " + resolve(process.env.SUNSHINE_ASSETS_DIR,"assets/web")); - assetsDstPath = resolve(process.env.SUNSHINE_ASSETS_DIR,"assets/web") + let path = resolve(fs.realpathSync(process.env.SUNSHINE_ASSETS_DIR), "assets/web"); + console.log("Using destdir from Cmake: " + path); + assetsDstPath = path; } }