## Current Behavior Copy assets plugin for Vite is not copying files in watch mode when those files are changed. This is due to the path being incorrect after calculation. There is also no indication to the user that the copy completed at all. ## Expected Behavior Fix path calculation to allow copy to occur correctly Output the relative dest of the file after copy completed. ## Related Issue(s) Fixes #30141
This commit is contained in:
parent
e8647df08a
commit
30f5a52d96
@ -55,6 +55,7 @@
|
||||
"npm-package-arg": "11.0.1",
|
||||
"npm-run-path": "^4.0.1",
|
||||
"ora": "5.3.0",
|
||||
"picocolors": "^1.1.0",
|
||||
"picomatch": "4.0.2",
|
||||
"semver": "^7.5.3",
|
||||
"source-map-support": "0.5.19",
|
||||
|
||||
@ -12,8 +12,9 @@ import * as path from 'node:path';
|
||||
import ignore from 'ignore';
|
||||
import { globSync } from 'tinyglobby';
|
||||
import { AssetGlob } from './assets';
|
||||
import { logger } from '@nx/devkit';
|
||||
import { logger, workspaceRoot } from '@nx/devkit';
|
||||
import { ChangedFile, daemonClient } from 'nx/src/daemon/client/client';
|
||||
import { dim } from 'picocolors';
|
||||
|
||||
export type FileEventType = 'create' | 'update' | 'delete';
|
||||
|
||||
@ -52,6 +53,9 @@ export const defaultFileEventHandler = (events: FileEvent[]) => {
|
||||
} else {
|
||||
logger.error(`Unknown file event: ${event.type}`);
|
||||
}
|
||||
const eventDir = path.dirname(event.src);
|
||||
const relativeDest = path.relative(eventDir, event.dest);
|
||||
logger.log(`\n${dim(relativeDest)}`);
|
||||
});
|
||||
};
|
||||
|
||||
@ -166,7 +170,9 @@ export class CopyAssetsHandler {
|
||||
async processWatchEvents(events: ChangedFile[]): Promise<void> {
|
||||
const fileEvents: FileEvent[] = [];
|
||||
for (const event of events) {
|
||||
const pathFromRoot = path.relative(this.rootDir, event.path);
|
||||
const pathFromRoot = event.path.startsWith(this.rootDir)
|
||||
? path.relative(this.rootDir, event.path)
|
||||
: event.path;
|
||||
for (const ag of this.assetGlobs) {
|
||||
if (
|
||||
picomatch(ag.pattern)(pathFromRoot) &&
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user