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

推荐订阅源

T
Threatpost
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
Recent Announcements
Recent Announcements
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
MongoDB | Blog
MongoDB | Blog
U
Unit 42
B
Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
LangChain Blog
Stack Overflow Blog
Stack Overflow Blog
P
Privacy International News Feed
L
LINUX DO - 最新话题
博客园_首页
博客园 - Franky
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tor Project blog
V
Visual Studio Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Privacy & Cybersecurity Law Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
Kaspersky official blog
C
Cisco Blogs
博客园 - 【当耐特】
阮一峰的网络日志
阮一峰的网络日志
I
Intezer
罗磊的独立博客
MyScale Blog
MyScale Blog
Last Week in AI
Last Week in AI
A
About on SuperTechFans
G
GRAHAM CLULEY
Y
Y Combinator Blog
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
D
DataBreaches.Net
The Hacker News
The Hacker News
Spread Privacy
Spread Privacy
AWS News Blog
AWS News Blog
I
InfoQ
T
The Exploit Database - CXSecurity.com
Simon Willison's Weblog
Simon Willison's Weblog
博客园 - 叶小钗
Project Zero
Project Zero

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 Watch and Rebuild Storybook Dependencies with Nx | 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 A Practical Guide on Effective AI Use - AI as Your Peer Programmer | Nx Blog
Deploying a PNPM Monorepo to Cloudflare Pages | Nx Blog
Juri Strumpflohner · 2026-04-20 · via Nx Blog

Deploying from a monorepo with multiple apps comes down to one requirement: only build and redeploy the apps that actually changed. Cloudflare Pages itself gives you fast static hosting with a global edge, custom domains, and a generous free tier. The trick is wiring it up so a push that only touches app1 doesn't rebuild and redeploy app2, app3, and everything else.

The setup in this post works for any pnpm or npm workspace. I use Nx as the task scheduler on top of the workspace because for the deployment setup it gives me an important thing: a project graph for computing what's affected by a change.

As a result I can declare a new deploy target on each deployable app, then let one generic GitHub Actions workflow run nx affected -t deploy and push results to Cloudflare Pages with wrangler.

Two paths for deploying

Cloudflare Pages offers two deployment models:

  1. Git integration. Point CF Pages at a GitHub repo, give it a build command and an output directory. Every push triggers a build in CF's container.
  2. Direct upload. You build the site somewhere else (e.g. GitHub actions), then call wrangler pages deploy <dist> to publish the artifacts.

Both ways work with a monorepo. For the GitHub integration you need to make sure though that you define the build watch paths so you don't build and redeploy projects you didn't touch in your monorepo.

While this works, it is tricky because it won't let you dynamically capture project dependencies. Say you have an app app1 (apps/app1) which imports from pkg1 (packages/pkg1), you'd have to statically define a watch path glob that captures both. If tomorrow you change your workspace in a way where app1 -> pkg1 -> pkg2 those changes wouldn't be captured automatically.

This is exactly where Nx comes in. Nx affected relies on the project graph to dynamically discover affected projects, following the dependency chain as it evolves.

The deploy target

Instead of hardcoding a deploy step per app in the workflow, create a deploy target on those apps you want to deploy to Cloudflare. Each deployable app declares its own in package.json:

{
  "name": "juriweb",
  "nx": {
    "targets": {
      "deploy": {
        "executor": "nx:run-commands",
        "options": {
          "command": "pnpm dlx wrangler pages deploy dist --project-name=juriweb --branch=$DEPLOY_BRANCH",
          "cwd": "{projectRoot}"
        },
        "dependsOn": ["build"],
        "cache": false
      }
    }
  }
}

Three things worth calling out.

cwd: "{projectRoot}". Nx's nx:run-commands defaults to running from the workspace root. That means dist would resolve to /workspace-root/dist, not /workspace-root/apps/juriweb/dist. Set cwd to the project root and dist resolves where you expect it.

dependsOn: ["build"]. This defines a so-called task pipeline so that Nx runs build before deploy. On a run where nothing changed, build is an instant cache hit and deploy uploads the last-good artifact.

cache: false. Critical. A cached deploy is not a deploy. If Nx cached the deploy task by its inputs, a re-run with no changes would skip the actual wrangler call entirely, and Cloudflare would never receive the update.

Adding a second deployable app is now a three-line copy of the same block. The workflow stays untouched.

The workflow

Because discovery runs through nx affected, the workflow is short:

name: Deploy affected (Cloudflare Pages)

on:
  push:
    branches: [main]
  pull_request:

permissions:
  actions: read
  contents: read
  deployments: write

env:
  NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_CI_TOKEN }}

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 0 }

      - uses: actions/setup-node@v4
        with: { node-version: 24 }

      - run: corepack enable pnpm
      - run: pnpm install --frozen-lockfile

      - uses: nrwl/nx-set-shas@v4

      - name: Deploy affected to Cloudflare Pages
        env:
          CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          DEPLOY_BRANCH: ${{ github.head_ref || github.ref_name }}
        run: pnpm exec nx affected -t deploy --parallel=3

That single nx affected -t deploy command does the discovery, the build (via dependsOn), and the deploy.

Two vars worth noting.

nx-set-shas sets the base SHA for affected. It queries the GitHub API for the last successful run on the base branch and sets NX_BASE and NX_HEAD env vars. That's what makes nx affected compute against "what actually changed since the last green CI" instead of against HEAD, which would report everything as affected on every push. The workflow needs actions: read for the API query to succeed.

DEPLOY_BRANCH. Cloudflare Pages uses the branch name to create preview aliases at <branch-slug>.<cf-project>.pages.dev. head_ref is set in PR context, ref_name in push context. This expression gives you one rule that produces clean preview URLs in both.

Secrets and one-time setup

Three GitHub Actions secrets:

  • CLOUDFLARE_API_TOKEN: create a custom token in the Cloudflare dashboard with the single permission Account → Cloudflare Pages → Edit. Don't use the "Edit Cloudflare Workers" preset, it grants far more than this workflow needs.
  • CLOUDFLARE_ACCOUNT_ID: visible in the Cloudflare dashboard sidebar, or via wrangler whoami.
  • NX_CLOUD_CI_TOKEN: from your Nx Cloud workspace settings.

Before the first deploy runs, create the CF Pages project so wrangler has somewhere to upload to:

pnpm dlx wrangler pages project create juriweb --production-branch=main

Wrapping up

So, to summarize:

  • we declare a deploy target for the apps we want to deploy
  • we use Nx and its affected command to automatically determine which apps require deployment
  • we use Cloudflare's wrangler CLI to deploy the app

The affected change detection doesn't depend on static globs but is dynamically calculated based on the Nx project graph and therefore works as we evolve our monorepo over time.

The same pattern works beyond Cloudflare Pages. Swap wrangler pages deploy for whatever your host's CLI is and the rest of the structure carries over.

Learn More