1

I'm using Yarn workspace for my Gatsby project. I created a Gatsby theme called "milan-site-theme" it lives in the root directory.

I also created 4 sites that use the "milan-site-theme" as a dependency. Those 4 sites live in the packages directory.

I understand whenever I make a change in the "milan-site-theme", this will affect all the sites. The Gatsby cloud detects the change and rebuilds all the sites concurrently and that makes sense and that's what I expect.

However, when I make a change to ONLY one of those sites in the packages directory, Gatsby cloud is rebuilding all the other sites as well. Is this the right behavior? This doesn't make sense to me. Now I only have 4 sites, but I know I will add a lot more soon. Am I missing anything? Here's the setup

And here's the main package.json

{
  "name": "milan-gatsby-yarn",
  "private": true,
  "version": "1.0.0",
  "license": "0BSD",
  "scripts": {
    "build": "yarn workspace albany build"
  },
  "workspaces": [
    "milan-site-theme",
    "packages/nebraska/*",
    "packages/newyork/*",
    "packages/texas/*",
    "packages/wisconsin/*"
  ],
  "packageManager": "yarn@3.2.0",
  "dependencies": {
    "firebase": "^9.8.4",
    "gatsby-plugin-gatsby-cloud": "^4.22.0",
    "gatsby-plugin-page-creator": "^4.18.0"
  }
}

And here's one of the sites package.json (Houston Site for instance)

{
  "name": "houston",
  "version": "1.0.0",
  "author": "my_email_goes_here",
  "license": "MIT",
  "scripts": {
    "develop": "gatsby develop",
    "build": "gatsby build",
    "clean": "gatsby clean"
  },
  "dependencies": {
    "gatsby": "^4.18.0",
    "milan-site-theme": "*",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  }
}

Note: the rest of the sites package.json look identical except for the name prop

Finally, here's the milan-site-theme package.json

{
  "name": "milan-site-theme",
  "version": "1.0.0",
  "main": "index.js",
  "author": "my_email_goes_here",
  "license": "MIT",
  "peerDependencies": {
    "gatsby": "*",
    "node-fetch": "*",
    "react": "*",
    "react-dom": "*"
  },
  "dependencies": {
    "@loadable/component": "^5.15.2",
    "@u-wave/react-vimeo": "^0.9.8",
    "axios": "^0.27.2",
    "bootstrap": "^5.1.3",
    "firebase": "^9.8.4",
    "formik": "^2.2.9",
    "gatsby-plugin-breakpoints": "^1.3.7",
    "gatsby-plugin-image": "^2.18.0",
    "gatsby-plugin-manifest": "^4.20.0",
    "gatsby-plugin-page-creator": "^4.18.0",
    "gatsby-plugin-sharp": "^4.18.0",
    "gatsby-plugin-sitemap": "^5.20.0",
    "gatsby-plugin-smoothscroll": "^1.2.0",
    "gatsby-source-filesystem": "^4.18.0",
    "gatsby-transformer-json": "^4.20.0",
    "gatsby-transformer-sharp": "^4.18.0",
    "gbimage-bridge": "^0.2.1",
    "qs": "^6.10.5",
    "react-bootstrap": "^2.4.0",
    "react-countup": "^6.3.0",
    "react-datepicker": "^4.8.0",
    "react-detect-offline": "^2.4.5",
    "react-helmet": "^6.1.0",
    "react-icons": "^4.3.1",
    "react-input-mask": "^2.0.4",
    "react-slick": "^0.29.0",
    "react-split": "^2.0.14",
    "react-twitter-embed": "^4.0.4",
    "react-twitter-widgets": "^1.11.0",
    "react-visibility-sensor": "^5.1.1",
    "slick-carousel": "^1.8.1",
    "to-words": "^3.2.0",
    "yup": "^0.32.11"
  }
}

Ferran Buireu
  • 28,630
  • 6
  • 39
  • 67
Ahmad_SY
  • 11
  • 1

1 Answers1

0

The problem is because gatsby cloud doesn't have the notion of a "UI library" and a "website". While it does know the base directory, what triggers a build is pushing changes to the repo where the site lives - if you are using a monorepo there is no way around it unless you disable automatic builds

Pietro Coelho
  • 1,894
  • 1
  • 26
  • 34