Skip to content
Go back

Running Vite Preview and Using Bun for Background Processes

Edit page

Running Vite Preview and Using Bun for Background Processes

Question: How to start and background vite preview and exit 0

Use nohup or a process manager:

nohup bunx vite preview &

To ensure it exits cleanly:

bunx vite preview & sleep 1 && exit 0

Tips:

Question: How to do this with bun spawn

Using Bun’s spawn:

const { spawn } = require("bun");
spawn(["vite", "preview"], {
  stdout: "inherit",
  stderr: "inherit",
  detached: true,
});

Tips:


Edit page
Share this post on:

Previous Post
Running Vite Preview and Using Bun for Background Processes
Next Post
Injecting Environment Variables in HTML Using EJS