Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Apr 26, 2024
2 parents 05b4dad + 5f144d5 commit 30c481a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/five-planets-grin.md
@@ -0,0 +1,5 @@
---
"@remix-run/dev": patch
---

Fix `dest already exists` error when running `remix vite:build`
9 changes: 7 additions & 2 deletions packages/remix-dev/vite/plugin.ts
Expand Up @@ -830,6 +830,11 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => {
return JSON.parse(manifestContents) as Vite.Manifest;
};

let getViteManifestFilePaths = (viteManifest: Vite.Manifest): Set<string> => {
let filePaths = Object.values(viteManifest).map((chunk) => chunk.file);
return new Set(filePaths);
};

let getViteManifestAssetPaths = (
viteManifest: Vite.Manifest
): Set<string> => {
Expand Down Expand Up @@ -1403,7 +1408,7 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => {
let ssrViteManifest = await loadViteManifest(serverBuildDirectory);
let clientViteManifest = await loadViteManifest(clientBuildDirectory);

let clientAssetPaths = getViteManifestAssetPaths(clientViteManifest);
let clientFilePaths = getViteManifestFilePaths(clientViteManifest);
let ssrAssetPaths = getViteManifestAssetPaths(ssrViteManifest);

// We only move assets that aren't in the client build, otherwise we
Expand All @@ -1415,7 +1420,7 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => {
let movedAssetPaths: string[] = [];
for (let ssrAssetPath of ssrAssetPaths) {
let src = path.join(serverBuildDirectory, ssrAssetPath);
if (!clientAssetPaths.has(ssrAssetPath)) {
if (!clientFilePaths.has(ssrAssetPath)) {
let dest = path.join(clientBuildDirectory, ssrAssetPath);
await fse.move(src, dest);
movedAssetPaths.push(dest);
Expand Down

0 comments on commit 30c481a

Please sign in to comment.