惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

SecWiki News
SecWiki News
量子位
The Cloudflare Blog
美团技术团队
T
The Exploit Database - CXSecurity.com
博客园 - 【当耐特】
Spread Privacy
Spread Privacy
P
Proofpoint News Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 三生石上(FineUI控件)
T
Tor Project blog
博客园 - 司徒正美
宝玉的分享
宝玉的分享
T
Threatpost
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Secure Thoughts
T
Threat Research - Cisco Blogs
Hacker News: Ask HN
Hacker News: Ask HN
Jina AI
Jina AI
博客园 - 聂微东
A
Arctic Wolf
I
Intezer
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Know Your Adversary
Know Your Adversary
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
爱范儿
爱范儿
Hugging Face - Blog
Hugging Face - Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
小众软件
小众软件
T
Tailwind CSS Blog
The Hacker News
The Hacker News
L
LINUX DO - 最新话题
Hacker News - Newest:
Hacker News - Newest: "LLM"
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
TaoSecurity Blog
TaoSecurity Blog
Project Zero
Project Zero
博客园 - 叶小钗
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Cloudbric
Cloudbric
雷峰网
雷峰网
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
大猫的无限游戏
大猫的无限游戏
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Troy Hunt's Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
V2EX - 技术
V2EX - 技术
The GitHub Blog
The GitHub Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog

Nx Blog

Sharing Tailwind CSS Styles Across Apps in a Monorepo | Nx Blog How SiriusXM Stays Competitive by Iterating and Getting to Market Fast | Nx Blog Agentic Experience Is the New Developer Experience | Nx Blog Nx Joins the Linux Foundation and the Agentic AI Foundation | Nx Blog A Monorepo Is NOT a Monolith | Nx Blog Why we deleted (most of) our MCP tools | Nx Blog Teach Your AI Agent How to Work in a Monorepo | Nx Blog How Broadcom stays efficient and nimble with monorepos | Nx Blog Why Monorepos are King in the Age of AI | Nx Blog Nx 2026 Roadmap: Expanding Agent Autonomy, Improving Performance, Better Polyglot and More | Nx Blog End to End Autonomous AI Agent Workflows with Nx | Nx Blog Autonomous Agents at Scale | Nx Blog Scaling 700+ Projects: How Nx Became a 'No-Brainer' for Caseware | Nx Blog Configure Tailwind v4 with Angular in an Nx Monorepo | Nx Blog The Missing Multiplier for AI Agent Productivity | Nx Blog A Year of Nx Webinars | Nx Blog Wrapping Up 2025 | Nx Blog Nx 22.3 Release: Angular 21 Support, tsgo Compiler, and Prettier v3 | Nx Blog Nx Cloud Release: Agent Resource Usage | Nx Blog Nx Platform Outperforms DIY Cache by 5x | Nx Blog An Nx Carol: Past, Present, and Future of Your Monorepo | Nx Blog Nx 22.1 Release: Terminal UI on Windows, Storybook 10, Vitest 4, and more! | Nx Blog The Compounding Effect: How Nx Features Multiply Performance Gains | Nx Blog 10 Monorepo Myths Debunked: Separating Fact from Fiction | Nx Blog Nx Cloud Release: Enterprise Task Analytics | Nx Blog Book - React for Enterprise: Timeless Architecture for Enterprise Apps | Nx Blog Beyond Remote Cache: Unlock 70% More CI Performance | Nx Blog Nx 22 Release: Expanding the build platform | Nx Blog What's the Point of Generating All This Code If You Can't Merge It? | Nx Blog What's New in Nx Self-Healing CI | Nx Blog Nx Highlights: Smarter AI integration, all-new graph UI, and big new versions of your favorite tools | Nx Blog Making the Case for Smarter Monorepos, and How to Not Get Fooled by Myths | Nx Blog Integrating Biome in 20 Minutes | Nx Blog S1ngularity - What Happened, How We Responded, What We Learned | Nx Blog Stop Babysitting Your PRs: Self-Healing CI Cuts Time to Green by 50% | Nx Blog UKG Unifies Their Codebase and Eliminates CI Overhead to Focus on Customer Value | Nx Blog How Git Worktrees Changed My AI Agent Workflow | Nx Blog Nx Cloud Workspace Graph: See Your Organization's Code Structure Like Never Before | Nx Blog Seamless Java Deployment in Nx Using Docker | Nx Blog Getting Mobile Into Your Monorepo: Android + Nx | Nx Blog Polyglot Projects Made Easy: Integrating Spring Boot into an Nx Workspace | Nx Blog The Journey of the Nx Plugin for Gradle: From Prototype to Production | Nx Blog Combining Predictability and Intelligence With Nx Generators and AI | Nx Blog A New UI For The Humble Terminal | Nx Blog Continuous tasks are a huge DX improvement | Nx Blog New and Improved Module Federation Experience with Nx | Nx Blog A New UI for Nx Migration | Nx Blog Custom Task Runners and Self-Hosted Caching Changes | Nx Blog Enterprise Angular Monorepo Patterns | Nx Blog Using Rspack with Angular | Nx Blog Angular Architecture Guide To Building Maintainable Applications at Scale | Nx Blog Modern Angular Testing with Nx | Nx Blog Nx Update: 20.5 | Nx Blog Are Monorepos the Answer to Better AI-Assisted Development? | Nx Blog Making Cursor Smarter with an MCP Server For Nx Monorepos | Nx Blog React Development for 2025 | Nx Blog Using Apollo GraphQL in an Nx Workspace | Nx Blog Angular State Management for 2025 | Nx Blog Tailoring Nx for Your Organization | Nx Blog Nx Cloud Pipelines Come To Nx Console | Nx Blog Define the relationship with monorepos | Nx Blog See your affected project graph in Nx Cloud | Nx Blog Handling CORS In Your Workspace | Nx Blog Improve your architecture and CI pipeline times with Nx projects | Nx Blog Announcing Nx 20 | Nx Blog Introducing Nx Powerpack | Nx Blog Nx 19.5 is here! Stackblitz, Bun, Incremental Builds for Vite, Gradle Test Atomizer | Nx Blog Introducing Explain with AI | Nx Blog Nx Enterprise Podcast Episode 2: Tine Kondo | Nx Blog Monorepos and CI can be a Mess - Here's How Nx and Nx Cloud Fixed It | Nx Blog Nx Enterprise Podcast Episode 1: Hicham El Hammouchi | Nx Blog Nx 19.0 Release!! | Nx Blog Manage Your Gradle Project using Nx | Nx Blog Making the Argument for Monorepos | Nx Blog Reliable CI. A new execution model fixing both flakiness and slowness | Nx Blog Monorepos - Why Speed Matters | Nx Blog Nx Agents Walkthrough: Effortlessly Fast CI Built for Monorepos | Nx Blog Launch Nx Week Recap | Nx Blog Versioning and Releasing Packages in a Monorepo | Nx Blog Fast, Effortless CI | Nx Blog Introducing @nx/nuxt Enhanced Nuxt.js Support in Nx | Nx Blog What if Nx Plugins Were More Like VSCode Extensions | Nx Blog Monorepos: the Benefits, Challenges, and Importance of Tooling Support | Nx Blog Nx — Highlights of 2023 | Nx Blog Nx 17.2 Update | Nx Blog Unit Testing Expo Apps With Jest | Nx Blog Nx Docs AI Assistant | Nx Blog State Management Nx React Native/Expo Apps with TanStack Query and Redux | Nx Blog Nx 17 has Landed | Nx Blog Nx Conf 2023 — Recap | Nx Blog Nx Raises $16M Series A | Nx Blog Introducing Playwright Support for Nx | Nx Blog Nx 16.8 Release!!! | Nx Blog Step-by-Step Guide to Creating an Expo Monorepo with Nx | Nx Blog Qwikify your Development with Nx | Nx Blog Create Your Own create-react-app CLI | Nx Blog Storybook Interaction Tests in Nx | Nx Blog Evergreen Tooling — More than Just CodeMods | Nx Blog Nx 16.5 Release!!! | Nx Blog A Practical Guide on Effective AI Use - AI as Your Peer Programmer | Nx Blog
Watch and Rebuild Storybook Dependencies with Nx | Nx Blog
Juri Strumpflohner · 2025-10-30 · via Nx Blog

This came up in our Discord: A Storybook setup in a library that depends on another buildable package in the monorepo. The problem? Whenever you run Storybook and change something in the buildable package, you won't see the effect right away. You need to manually rebuild it, and only then will Storybook pick up the changes.

Let me show you how we can fix this with Nx's workspace watching feature. (Demo repo included in the links at the very end.)

The Problem: Buildable Libraries and Storybook

I reproduced the setup. Here's what we're working with:

Project graph showing Storybook library depending on UI library

We have a Storybook library (feat-create-orders) that depends on a buildable library (ui). The buildable library is configured to point to its pre-built output in the dist folder. This means everyone consuming this library in the monorepo will point to the pre-built version rather than the source files.

Here's what the ui library's package.json looks like:

{
  "name": "@storybooknx/ui",
  "version": "0.0.1",
  "type": "module",
  "main": "./dist/index.js",
  "module": "./dist/index.js",
  "types": "./dist/index.d.ts",
  "exports": {
    "./package.json": "./package.json",
    ".": {
      "@storybooknx/source": "./src/index.ts",
      "types": "./dist/index.d.ts",
      "import": "./dist/index.js",
      "default": "./dist/index.js"
    }
  }
}

Notice how the main entry points point to *.js files. This means we need to keep the dist folder up-to-date whenever we make changes to the source files. Otherwise, Storybook won't reflect our changes.

The Solution: Nx Workspace Watching

Nx actually has a feature that allows you to watch files and automatically run commands when they change. You can find all the details in the Workspace Watching guide in the Nx docs.

The key is the nx watch command which lets you watch specific projects and run a command whenever a change is detected. Here's the basic syntax:

npx nx watch --projects=@storybooknx/feat-create-orders --includeDependentProjects -- nx build-deps @storybooknx/feat-create-orders

For our Storybook setup, we need to watch all dependencies (--includeDependentProjects) of the Storybook package and rebuild them whenever something changes. This way, Storybook's Vite HMR server picks up the changes and refreshes automatically.

Setting It Up: Step by Step

To make this work, we need to configure two targets in our Storybook library's configuration. You can also follow along in my example repository.

1. The build-deps Target

This is a simple no-op target that serves as a hook point. The magic happens through its dependsOn configuration, which tells Nx to build all dependencies of the current project:

packages/feat-create-orders/package.json

{
  "name": "@storybooknx/feat-create-orders",
  "version": "0.0.1",
  "nx": {
    "targets": {
      "build-deps": {
        "dependsOn": ["^build"],
        "executor": "nx:noop"
      }
    }
  }
}

The ^build in dependsOn means: "build all my dependencies first." Since this is a noop executor, it won't do anything itself, but Nx will ensure all dependencies are built before this target completes.

2. The watch-deps Target

This is where the actual watching happens:

packages/feat-create-orders/package.json

{
  "name": "@storybooknx/feat-create-orders",
  "version": "0.0.1",
  "nx": {
    "targets": {
      "build-deps": {
        "dependsOn": ["^build"],
        "executor": "nx:noop"
      },
      "watch-deps": {
        "continuous": true,
        "dependsOn": ["build-deps"],
        "executor": "nx:run-commands",
        "options": {
          "command": "nx watch --projects @storybooknx/feat-create-orders --includeDependentProjects -- nx build-deps @storybooknx/feat-create-orders"
        }
      }
    }
  }
}

Let's break down what's happening:

  • continuous: true - Marks this as a long-running task
  • dependsOn: ["build-deps"] - Ensures dependencies are built before watching starts
  • The command watches the current project and all its dependencies
  • When a change is detected, it runs nx build-deps which triggers rebuilding

3. Update the Storybook Target

Finally, we need to make the Storybook target depend on these new targets:

packages/feat-create-orders/package.json

{
  "nx": {
    "targets": {
      "storybook": {
        "dependsOn": ["^build", "watch-deps"]
      },
      "build-deps": {
        "dependsOn": ["^build"],
        "executor": "nx:noop"
      },
      "watch-deps": {
        "continuous": true,
        "dependsOn": ["build-deps"],
        "executor": "nx:run-commands",
        "options": {
          "command": "nx watch --projects @storybooknx/feat-create-orders --includeDependentProjects -- nx build-deps @storybooknx/feat-create-orders"
        }
      }
    }
  }
}

Now when you run nx storybook feat-create-orders, Nx will:

  1. Build all dependencies (^build)
  2. Start the watch command in parallel (watch-deps)
  3. Serve Storybook

Copy Configuration from Nx Console

If you're using a Vite or React app with Nx, you likely already have the watch-deps target configured automatically. You can easily copy the target configuration from Nx Console! Just open the project panel, navigate to the watch-deps target, and click "Copy Target Configuration." Then paste it into your Storybook library's package.json and adjust as needed. Check the video for the details

See It in Action

Let me show you the final developer experience:

When you run:

nx storybook feat-create-orders

You'll see the Nx terminal split into two panels:

  • Top panel: Storybook dev server
  • Bottom panel: The watch-deps process monitoring for changes

Nx TUI showing the storybook run and watch in 2 panels

When you make any change in the UI package, you'll see the bottom panel running the watch-deps command update, rebuild the package and hence the Storybook Vite HMR server will pick it up and show the live result.

Watch-deps and Build-deps by Default in Nx v22

nx watch is powerful and crucial in a monorepo to maintain good DX by automatically rebuilding buildable packages. Nx already adds this to applications and other buildable packages. While recording the video (you can actually see it in the video itself), I realized this should be the default experience for Nx + Storybook.

I submitted a PR right after finishing the video, and this now ships by default with Nx v22. The power of open source!

Conclusion

Setting up automatic rebuilding for your Storybook dependencies transforms the developer experience from frustrating to seamless. No more manual rebuilds, no more stale changes - just edit your code and see it update in Storybook immediately.

The combination of Nx's workspace watching, intelligent caching, and task orchestration makes this setup not only possible but performant. Give it a try and experience the difference!


Learn More

Also, make sure to check out: