From 985107cac3ff84b544aeeaa1876d91739df5994f Mon Sep 17 00:00:00 2001 From: Colum Ferry Date: Wed, 2 Apr 2025 13:30:55 +0100 Subject: [PATCH] fix(vite): ensure nxCopyAssetsPlugin outputs assets to correct location #28786 (#30585) ## Current Behavior The `nxCopyAssetsPlugin` from `@nx/vite` does not output the asset files to the correct location. It prepends the `rootDir` even when the `outDir` in the `vite.config` resolves to contain the `rootDir`. ## Expected Behavior Only prepend the `rootDir` when it does not already exist ## Related Issue(s) Fixes #28786 --- packages/vite/plugins/nx-copy-assets.plugin.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/vite/plugins/nx-copy-assets.plugin.ts b/packages/vite/plugins/nx-copy-assets.plugin.ts index bcbdd6c273..7f23be0a92 100644 --- a/packages/vite/plugins/nx-copy-assets.plugin.ts +++ b/packages/vite/plugins/nx-copy-assets.plugin.ts @@ -31,7 +31,9 @@ export function nxCopyAssetsPlugin(_assets: (string | AssetGlob)[]): Plugin { handler = new CopyAssetsHandler({ rootDir: workspaceRoot, projectDir: config.root, - outputDir: join(config.root, config.build.outDir), + outputDir: config.build.outDir.startsWith(config.root) + ? config.build.outDir + : join(config.root, config.build.outDir), assets, }); if (this.meta.watchMode && isDaemonEnabled()) {