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
This commit is contained in:
Colum Ferry 2025-04-02 13:30:55 +01:00 committed by GitHub
parent ebd39bb2ae
commit 985107cac3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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()) {