Amplify: install devDependencies during build (Tailwind/PostCSS need them)

@tailwindcss/postcss lives in devDependencies (along with the rest of
the PostCSS toolchain). When NODE_ENV=production is set in the Amplify
build environment, npm ci skips devDependencies — and next build then
fails resolving @tailwindcss/postcss while compiling globals.css.

amplify.yml now passes --include=dev to npm ci so the build always
installs everything regardless of NODE_ENV. AMPLIFY_DEPLOY.md updated
to warn against setting NODE_ENV=production in the Amplify env vars
panel — it's redundant (Next sets it correctly) and an easy footgun.
This commit is contained in:
Joel Brock
2026-05-19 17:13:13 -07:00
parent 6e7df382c9
commit e90d007513
2 changed files with 10 additions and 2 deletions
+6 -1
View File
@@ -41,7 +41,12 @@ On the environment-variables screen, add the following. Required ones first:
| `CIVI_BASE_URL` | e.g. `https://crm.fci.coop` |
| `CIVI_API_KEY` | mark as **Secret** (eye icon on the value field) |
| `CIVI_SITE_KEY` | mark as **Secret** |
| `NODE_ENV` | `production` |
Do **not** set `NODE_ENV=production` in the Amplify panel. Amplify and Next
already set it correctly at runtime; setting it at build time causes
`npm ci` to skip devDependencies, which breaks the Tailwind/PostCSS step.
The `amplify.yml` in this repo guards against this with `--include=dev`,
but it's cleaner not to set it at all.
Optional, only if relevant:
+4 -1
View File
@@ -5,7 +5,10 @@ applications:
preBuild:
commands:
- nvm use $(cat .nvmrc) || nvm install $(cat .nvmrc)
- npm ci --cache .npm --prefer-offline
# --include=dev is required because the build needs PostCSS /
# Tailwind plugins which live in devDependencies; without it,
# NODE_ENV=production in the Amplify env causes npm to skip them.
- npm ci --include=dev --cache .npm --prefer-offline
build:
commands:
- npm run build