Within a monorepo (using Turborepo) is it possible to start dev and Storybook (lives in a child package) with a single command?

huangapple go评论69阅读模式
英文:

Within a monorepo (using Turborepo) is it possible to start dev and Storybook (lives in a child package) with a single command?

问题

在开发环境中,不是首先使用npm run dev(使用Turborepo)启动我的monorepo,然后进入Storybook所在的包并执行npm run storybook,是否有一种方法可以使用一个命令(即npm run dev)同时启动两者?

英文:

In a dev environment instead of spinning up my monorepo first with npm run dev (which uses Turborepo) then cd'ing into a package where Storybook lives and executing npm run storybook, is there a way to spin up both with one command (ie. npm run dev)?

答案1

得分: 1

是的,有的。
我建议您使用concurrently来实现这一点。您可以编写一个单独的运行配置,使用concurrently:

  • 首先,安装concurrently
npm i -D concurrently
  • 在您的package.json中引入一个新的脚本配置
{
  ...
  "scripts": {
    "dev": "...",
    "start": "concurrently -n dev,storybook -c yellow,green 'npm run dev' 'cd .storybook && npm run storybook dev -p 6006'"
  }
}
  • 然后您应该能够运行npm start
英文:

Yes, there is.
I'd recommend you to use concurrently for that. You can write a separate run config that uses concurrently:

  • first, install concurrently
npm i -D concurrently
  • introduce a new script configuration in your package.json
{
  ...
  "scripts": {
    "dev": "...",
    "start": "concurrently -n dev,storybook -c yellow,green 'npm run dev' 'cd .storybook && npm run storybook dev -p 6006'"
  }
}
  • you should then be able to run npm start.

huangapple
  • 本文由 发表于 2023年5月11日 02:10:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76221458.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定