Empty build directories after quitting npm run dev
#2922
Replies: 5 comments
-
I run Remix run inside an npm script inside PM2 (PM2 runs npm run dev) and it works correctly the delete of the build directory |
Beta Was this translation helpful? Give feedback.
-
Screen.Recording.2021-09-19.at.10.58.13.movHere you can see the behavior I'm referring to. Pay attention to the |
Beta Was this translation helpful? Give feedback.
-
Here is a patch file for fixing the issue. It seems that diff --git a/node_modules/@remix-run/dev/cli/commands.js b/node_modules/@remix-run/dev/cli/commands.js
index 2d6c2b2..460046b 100644
--- a/node_modules/@remix-run/dev/cli/commands.js
+++ b/node_modules/@remix-run/dev/cli/commands.js
@@ -89,9 +89,10 @@ async function watch(remixRootOrConfig, modeArg, onRebuildStart) {
}
}));
- signalExit__default['default'](() => {
+ process.on("SIGINT", () => {
fse.emptyDirSync(config$1.assetsBuildDirectory);
fse.emptyDirSync(config$1.serverBuildDirectory);
+ process.exit(0);
});
console.log(`💿 Built in ${prettyMs__default['default'](Date.now() - start)}`);
}
|
Beta Was this translation helpful? Give feedback.
-
Please look at my reproduction here: https://github.com/jensmeindertsma/using-signal-exit I've demonstrated there that the issue has to do with |
Beta Was this translation helpful? Give feedback.
-
I've now added a demo of |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When you run
npx remix run
and then terminate the server withCtrl-C
, the following code is executed:remix/packages/remix-dev/cli/commands.ts
Lines 91 to 94 in c1821e4
However, if you add a script to your
package.json
calleddev
which runsremix run
, when you terminate the server after runningnpm run dev
, this code is never called.It would be nice if the build directories were emptied even when running
remix run
through a NPM script.Beta Was this translation helpful? Give feedback.
All reactions