DEV Community

BarbWire
BarbWire

Posted on

Built a tiny CLI to scaffold Vite npm libraries + live consumer apps

I kept rebuilding the same setup over and over whenever starting a small npm library project:

  • Vite library config
  • example code
  • Vitest setup for example code
  • exports
  • watch mode
  • subpath/modifier exports
  • local consumer app
  • linking/testing workflow

So I finally turned my own workflow into a small CLI scaffolder.

It creates:

workspace/
├── app/        -> lightweight consumer test app
└── my-lib/     -> Vite library
Enter fullscreen mode Exit fullscreen mode

Features currently include:

  • Vite library mode
  • ESM + CJS builds
  • subpath exports
  • watch command
  • live local testing workflow
  • modifier structure example
  • minimal boilerplate

Install:

npm i -g create-lib-workspace
Enter fullscreen mode Exit fullscreen mode

Usage:

create-lib-workspace demo my-lib @demo/my-lib
Enter fullscreen mode Exit fullscreen mode

🔗 Go the github repo

Mainly built this for my own workflow, but maybe useful for others doing small utility/package development.

Curious how others structure their lib + live consumer setup these days.

Top comments (0)