Skip to content

Commit

Permalink
fix(vite): prevent asset copying when NX_GRAPH_CREATION is enabled (#…
Browse files Browse the repository at this point in the history
…30037)

This PR includes updates to the `nxCopyAssetsPlugin` function in the
`packages/vite/plugins/nx-copy-assets.plugin.ts` file to improve asset
handling and daemon integration.

The most important changes include adding a check for
`NX_GRAPH_CREATION`.

Additionally, it also contains a check to ensure that before attempting
to watch for file changes the daemon should be available.
  • Loading branch information
ndcunningham authored and jaysoo committed Feb 14, 2025
1 parent 75f3eec commit 5b4ea8e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/vite/plugins/nx-copy-assets.plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { join, relative } from 'node:path';
import type { Plugin, ResolvedConfig } from 'vite';
import { joinPathFragments, workspaceRoot } from '@nx/devkit';
import { isDaemonEnabled, joinPathFragments, workspaceRoot } from '@nx/devkit';
import { AssetGlob } from '@nx/js/src/utils/assets/assets';
import { CopyAssetsHandler } from '@nx/js/src/utils/assets/copy-assets-handler';

Expand All @@ -9,6 +9,8 @@ export function nxCopyAssetsPlugin(_assets: (string | AssetGlob)[]): Plugin {
let handler: CopyAssetsHandler;
let dispose: () => void;

if (global.NX_GRAPH_CREATION) return;

return {
name: 'nx-copy-assets-plugin',
configResolved(_config) {
Expand All @@ -32,7 +34,7 @@ export function nxCopyAssetsPlugin(_assets: (string | AssetGlob)[]): Plugin {
outputDir: join(config.root, config.build.outDir),
assets,
});
if (this.meta.watchMode) {
if (this.meta.watchMode && isDaemonEnabled()) {
dispose = await handler.watchAndProcessOnAssetChange();
}
},
Expand Down

0 comments on commit 5b4ea8e

Please sign in to comment.