From aeed10e53857048a78b3c2cb40c95a49ec7b95a5 Mon Sep 17 00:00:00 2001 From: Mark Dalgleish Date: Fri, 17 Nov 2023 15:00:02 +1100 Subject: [PATCH 1/2] fix(vite): disable redundant copyPublicDir option --- .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..5ccdb0a6f7f --- /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 `serverBuildDirectory`. 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, From c8d9a5044adb724cf9047120b7b643570bc97b8b Mon Sep 17 00:00:00 2001 From: Mark Dalgleish Date: Fri, 17 Nov 2023 15:06:48 +1100 Subject: [PATCH 2/2] update changeset --- .changeset/proud-otters-cheat.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/proud-otters-cheat.md b/.changeset/proud-otters-cheat.md index 5ccdb0a6f7f..b5fb8fc1108 100644 --- a/.changeset/proud-otters-cheat.md +++ b/.changeset/proud-otters-cheat.md @@ -2,4 +2,4 @@ "@remix-run/dev": patch --- -Fix redundant copying of assets from `public` directory in Vite build. This ensures that static assets aren't duplicated in `serverBuildDirectory`. This also fixes an issue where the build would break if `assetsBuildDirectory` was deeply nested within the `public` directory. +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.