I have a pnpm monorepo. In it I have a bunch of shared packages for types and atomic design components.
I then have two main websites. The marketing site and the app site.
Marketing runs Next as we need it for SEO
App runs a Vite application
So then I have a Netlify.toml file that specifies:
- marketing should use nextjs plugin
- app should just use the standard pnpm build command
So I setup the netlify.toml for this
- Scenario 1: next plugin at a global context. This successfully builds and deploys marketing, but breaks the build of app as it applies next build to a vite site. Implementing a plugin override at the app context does not fix this
- Scenario 2: add the next plugin at the marketing context in the netlfiy.toml. This then means both marketing and app build correctly. But the marketing site isn’t picked up as a next site and it doesn’t pick up the function, which means the marketing site doesn’t display and just gives a 404
So I believe either my netlify.toml has some syntax issue, there is a bug with how it’s been interpreted. I do use pnpm which supposedly causes issues, but I’ve created a .npmrc file in the root of the monorepo with this code
public-hoist-pattern[]=*
And my netlify.toml looks like the below: note how there is also a pnpm flag there too
# ==============================================================================
# Netlify Configuration for Demiton Monorepo v13 (Final - With PNPM Hoist Flag)
# ==============================================================================
# Global build settings applied to all projects.
[build]
# We always run commands from the monorepo root.
base = "/"
[build.environment]
NODE_VERSION = "22"
# Use the pnpm version from your local environment for consistency.
PNPM_VERSION = "10.12.1"
PNPM_FLAGS = "--shamefully-hoist"
# --- GLOBAL Redirects for Vite/SPA apps ---
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
# ==============================================================================
# CONTEXT-SPECIFIC BUILD SETTINGS
# ==============================================================================
# --- Staging Marketing Site (Next.js) ---
[context.demiton-staging]
command = "pnpm --filter @demiton/marketing-next build"
publish = "packages/ui/apps/marketing-next/.next"
# The Next.js plugin is now detected automatically because of the hoist flag.
# We do not need an explicit plugins block.
[[context.demiton-staging.plugins]]
package = "@netlify/plugin-nextjs"
# --- Staging Main App (Vite) ---
[context.demiton-app-staging]
command = "pnpm --filter @demiton/app build"
publish = "packages/ui/apps/app/dist"
# --- Production Marketing Site (Next.js) ---
[context.demiton-mktg]
command = "pnpm --filter @demiton/marketing-next build"
publish = "packages/ui/apps/marketing-next/.next"
[[context.demiton-mktg.plugins]]
package = "@netlify/plugin-nextjs"
# --- Production Main App (Vite) ---
[context.demiton-app]
command = "pnpm --filter @demiton/app build"
publish = "packages/ui/apps/app/dist"