Skip to content

Commit e5e3462

Browse files
committed
feat(vite): add logic to nxViteTsPaths:writeBundle to skip copying package.json file if it already exists in dest
The nxViteTsPaths plugin currently always copys the package.json file at the end of the build and does not check if the file was generated from the build process. This adds logic to check if the package.json file already exists in the dist path before copying to prevent overwriting generated files. Closes nrwl#30312
1 parent 4cc3a39 commit e5e3462

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/vite/plugins/nx-tsconfig-paths.plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ export function nxViteTsPaths(options: nxViteTsPathsOptions = {}) {
197197
if (isUsingTsSolutionSetup()) return;
198198
const outDir = options.dir || 'dist';
199199
const src = resolve(projectRoot, 'package.json');
200-
if (existsSync(src)) {
201-
const dest = join(outDir, 'package.json');
200+
const dest = join(outDir, 'package.json');
202201

202+
if (existsSync(src) && !existsSync(dest)) {
203203
try {
204204
copyFileSync(src, dest);
205205
} catch (err) {

0 commit comments

Comments
 (0)