Skip to content

Commit f7062e4

Browse files
fix(vite): disable redundant copyPublicDir option (#8039)
1 parent e6d1176 commit f7062e4

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.changeset/proud-otters-cheat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@remix-run/dev": patch
3+
---
4+
5+
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.

packages/remix-dev/vite/plugin.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,13 @@ export const remixVitePlugin: RemixVitePlugin = (options = {}) => {
519519
base: pluginConfig.publicPath,
520520
build: {
521521
...viteUserConfig.build,
522+
// By convention Remix builds into a subdirectory within the
523+
// public directory ("public/build" by default) so we don't want
524+
// to copy the contents of the public directory around. This also
525+
// ensures that we don't get caught in an infinite loop when
526+
// `assetsBuildDirectory` is nested multiple levels deep within
527+
// the public directory, e.g. "public/custom-base-dir/build"
528+
copyPublicDir: false,
522529
...(!isSsrBuild
523530
? {
524531
manifest: true,

0 commit comments

Comments
 (0)