Skip to content
GitHubBlueskydev.toRSS
Blog

From npm scripts or Vite Task

One command turns package.json scripts or Vite Task config into vx tasks. npm pre and post hooks keep their order.

bunx @vzn/vx-migrate turns your package.json scripts or Vite Task config into vx tasks. (Coming from Turbo or Nx? They have their own posts.)

npm calls prebuild before build and postbuild after it. The migrator puts the hooks into the task’s command, in that order, and tells you:

Terminal window
$ cat packages/app/package.json
{"name":"app","scripts":{"prebuild":"rimraf dist","build":"vite build","postbuild":"node scripts/copy.js"}}
$ bunx @vzn/vx-migrate --dry
─ vx-migrate 0.0.637 ─────────────────────────────────────────
from package.json scripts
dry run nothing written
tasks 1 todo
todo app#build: npm ran `prebuild` and `postbuild` around this script without being asked; folded into the command in that order
app#build: cache: add `inputs: { files: ['**'] }, outputs: { files: ['dist/**'] }, cache: true` with this package's real outputs, and narrow the inputs to what it reads …

The && list stops at the first part that fails. Arguments after -- reach build only, as with npm.

If your package manager skips these hooks (Yarn 2+, or npm with ignore-scripts), each hook stays its own task. Hooks like prepack never become tasks.

A vite-plus repo keeps tasks in each package’s vite.config.* under run. The migrator reads them the way vp run does:

Terminal window
$ bunx @vzn/vx-migrate --from vite-task

command, cwd, dependsOn and cache settings map across. A command starting with vp run x becomes a dependsOn edge.

Anything that does not map stays in the command with a TODO, so nothing gets lost.

The full mapping table is in the vx-migrate README. More at vznjs.github.io/vx.

Turborepo, Nx and other product names are trademarks of their owners. vx is not affiliated with or endorsed by them.