diff --git a/CHANGELOG.md b/CHANGELOG.md index 39b9c3d4f..fe2b3eb09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Ensure `--spacing(0)` is optimized to `0px` instead of `0` so it remains a `` when used in `calc(…)` ([#20319](https://github.com/tailwindlabs/tailwindcss/pull/20319)) - Lazily load `@parcel/watcher` when using the `--watch` flag in `@tailwindcss/cli`, so one-off builds and `--watch --poll` work when `@parcel/watcher` can't be loaded ([#20325](https://github.com/tailwindlabs/tailwindcss/issues/20325)) - Use explicit platform fonts instead of `system-ui` and `ui-sans-serif` so CJK text respects the page's `lang` attribute on Windows ([#19767](https://github.com/tailwindlabs/tailwindcss/issues/19767), [#19768](https://github.com/tailwindlabs/tailwindcss/issues/19768)) +- Prevent `@tailwindcss/upgrade` from rewriting ignored files when run from a subdirectory ([#20328](https://github.com/tailwindlabs/tailwindcss/issues/20328)) ## [4.3.2] - 2026-06-26 diff --git a/integrations/upgrade/index.test.ts b/integrations/upgrade/index.test.ts index 9e236e8fd..c8fa4c86b 100644 --- a/integrations/upgrade/index.test.ts +++ b/integrations/upgrade/index.test.ts @@ -3371,6 +3371,61 @@ test( }, ) +// https://github.com/tailwindlabs/tailwindcss/issues/20328 +test( + 'ignored files should not be touched when upgrading from a nested directory', + { + fs: { + 'pnpm-workspace.yaml': yaml` + # + packages: + - packages/* + `, + 'package.json': json` + { + "name": "root", + "private": true + } + `, + 'packages/css/package.json': json` + { + "name": "css-pkg", + "private": true, + "devDependencies": { + "tailwindcss": "^4", + "@tailwindcss/upgrade": "workspace:^" + } + } + `, + 'packages/css/src/input.css': css` + @import 'tailwindcss/utilities.css' layer(utilities) source(none); + `, + 'packages/css/src/index.html': html`
Hi
`, + + // Ensure files/folders ignored by a `.gitignore` in the root take effect + // when executing the upgrade tool from a sub-package. + '.gitignore': txt` + node_modules/ + `, + }, + }, + async ({ root, exec, fs, expect }) => { + await exec('git init', { cwd: root }) + + await exec('pnpm exec upgrade --force', { + cwd: path.join(root, 'packages/css'), + }) + + expect(await fs.dumpFiles('packages/css/node_modules/tailwindcss/utilities.css')) + .toMatchInlineSnapshot(` + " + --- packages/css/node_modules/tailwindcss/utilities.css --- + @tailwind utilities; + " + `) + }, +) + test( 'upgrade