From f7062e43079fba6edb3fd04642fb8cba3ba09c67 Mon Sep 17 00:00:00 2001 From: Mark Dalgleish Date: Sat, 18 Nov 2023 09:23:12 +1100 Subject: [PATCH] fix(vite): disable redundant copyPublicDir option (#8039) --- .changeset/proud-otters-cheat.md | 5 +++++ packages/remix-dev/vite/plugin.ts | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 .changeset/proud-otters-cheat.md diff --git a/.changeset/proud-otters-cheat.md b/.changeset/proud-otters-cheat.md new file mode 100644 index 00000000000..b5fb8fc1108 --- /dev/null +++ b/.changeset/proud-otters-cheat.md @@ -0,0 +1,5 @@ +--- +"@remix-run/dev": patch +--- + +Fix redundant copying of assets from `public` directory in Vite build. This ensures that static assets aren't duplicated in the server build directory. This also fixes an issue where the build would break if `assetsBuildDirectory` was deeply nested within the `public` directory. diff --git a/packages/remix-dev/vite/plugin.ts b/packages/remix-dev/vite/plugin.ts index 60e4fb4ec0b..dcdd2e1a32d 100644 --- a/packages/remix-dev/vite/plugin.ts +++ b/packages/remix-dev/vite/plugin.ts @@ -519,6 +519,13 @@ export const remixVitePlugin: RemixVitePlugin = (options = {}) => { base: pluginConfig.publicPath, build: { ...viteUserConfig.build, + // By convention Remix builds into a subdirectory within the + // public directory ("public/build" by default) so we don't want + // to copy the contents of the public directory around. This also + // ensures that we don't get caught in an infinite loop when + // `assetsBuildDirectory` is nested multiple levels deep within + // the public directory, e.g. "public/custom-base-dir/build" + copyPublicDir: false, ...(!isSsrBuild ? { manifest: true,