As I work on my nestjs application, I find myself needing to ensure that specific json files are copied to the dist directory. This is especially important for the "engines" folder, where the json files in src/engines must be replicated in dist/and prod.
The issue arises when nest start deletes the dist folder and recreates it with only d.ts, js, and js.map files, which results in the removal of my json files.
To address this issue, I attempted the following modifications in my package.json
scripts
:
"copy:json": "copyfiles -u 2 src/engines/**/*.json dist/engines",
"start": "nest start && yarn copy:json",
"start:dev": "nest start --watch && yarn copy:json",
"start:debug": "nest start --debug --watch && yarn copy:json",
"start:prod": "node dist/main && yarn copy:json",
Interestingly, when I run start:dev, the json files are still missing from the dist
directory.
However, executing yarn copy:json
on its own works perfectly fine by copying the right files to the correct location.