Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dest already exists error during Vite build #11501

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/remix-dev/vite/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,11 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = (_config) => {
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 @@ -1405,7 +1410,7 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = (_config) => {
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 @@ -1417,7 +1422,7 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = (_config) => {
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
Loading