I’m using vite + typescript + vue3, and there is a command build
like below.
I want to trigger the build
command once there is a file changed, how can I achieve it besides manually installing the nodemon.
BTW, both vue-tsc
and vite build
support –watch individually.
"scripts": {
"dev": "vite",
"build": "vue-tsc && vite build",
"preview": "vite preview"
},
2
Answers
To trigger the
build
command in your Vite + TypeScript + Vue 3 project whenever a file changes, you can usechokidar-cli
to watch your files and run the build script automatically. This way, you avoid manually installing and configuringnodemon
.Now just
npm run watch-build
You can also use
fs.watch
ordebounce
For non windows:
You can use
&
:This will make first command run in background, and then run the second.
I have tested in my local setup. While it does not open two terminals, it is easy to distinguish between the two processes as there is numbering in front of the output.