skip to content

In Tailwind CSS v4, why does a PostCSS config shrink to just @tailwindcss/postcss, and when would you pick another integration instead?

level: middleimportance: should knowfreq 11%

answer

  1. a build step of its own
  2. imports, prefixes, nesting
  3. the plugin moved packages
  4. Vite, PostCSS, CLI, webpack
  5. a fixed browser floor

basics

~10 s

Tailwind CSS v4 bundles @import files, adds vendor prefixes and flattens nesting itself, so postcss-import and Autoprefixer are redundant. Use @tailwindcss/vite with Vite, @tailwindcss/webpack (since 4.2) with webpack, and @tailwindcss/cli without a bundler.

solid answer

~40 s

Tailwind CSS v4 is a full CSS build step: it inlines `@import`ed files, adds vendor prefixes and flattens nesting with Lightning CSS, so `postcss-import` and `autoprefixer` come out of the config and `{ "@tailwindcss/postcss": {} }` is all that remains. The PostCSS plugin also moved: in v3 the `tailwindcss` package was the plugin, in v4 it is `@tailwindcss/postcss`. The choice of integration follows the existing build: `@tailwindcss/vite` is recommended for Vite projects, `@tailwindcss/webpack` (added in 4.2.0) for webpack, `@tailwindcss/cli` when there is no bundler, and the PostCSS plugin where a framework only exposes PostCSS. All four share one compiler and scanner. The output targets a fixed floor, Chrome 111, Safari 16.4 and Firefox 128, rather than a Browserslist query.

go deeper

for a junior

Recall the four v4 integrations and that Tailwind v4 handles imports and vendor prefixes itself, so the PostCSS config holds only @tailwindcss/postcss.

for a middle

Explain what v4 took over from postcss-import, autoprefixer and nesting plugins, why the plugin moved packages, and how to pick an integration from the existing build.

for a senior

Check the browser floor against the support policy before adopting, know the targets are fixed rather than Browserslist-driven, and strip redundant plugins and preprocessors from the path.

for a principal

Treat the floor and the build integration as platform decisions: one integration per build type across the organisation, and a support policy that names the floor explicitly.

## What v4 does by itself In Tailwind CSS v3 the `tailwindcss` package was itself a PostCSS plugin, and a typical setup ran three plugins: `postcss-import` to inline `@import`ed files, `tailwindcss`, and `autoprefixer` to add vendor prefixes. Tailwind CSS v4 is a complete CSS build step on its own: - It **bundles `@import`ed CSS** at build time, so `@import "./typography.css";` is inlined without another tool. - It **adds vendor prefixes** itself. - It **flattens nested CSS**, using Lightning CSS under the hood. - It **minifies** when its optimisation pass is on. That is why the upgrade guide tells you to remove `postcss-import` and `autoprefixer`, and why the PostCSS plugin moved to its own package: ```javascript // postcss.config.mjs export default { plugins: { "@tailwindcss/postcss": {}, }, }; ``` The same reasoning explains the advice not to run v4 behind a preprocessor such as Sass: the documentation calls Tailwind itself your preprocessor, since it already handles imports, nesting and prefixing, and native CSS variables replace preprocessor variables. ## One engine, four integrations | Package | Fits | Notes | |---|---|---| | `@tailwindcss/vite` | projects built with Vite | recommended over the PostCSS plugin there, for performance | | `@tailwindcss/postcss` | builds that already run PostCSS | the v4 home of what used to be the `tailwindcss` plugin | | `@tailwindcss/cli` | no bundler at all | `npx @tailwindcss/cli -i ./src/app.css -o ./dist/app.css --watch` | | `@tailwindcss/webpack` | webpack builds | a loader added in **4.2.0**, placed in the CSS rule's loader chain | All four run the same compiler and the same scanner, so the same stylesheet produces the same utilities. The choice follows the build you already have, not the features you want: 1. If the app is built with Vite, use the Vite plugin. 2. If the framework exposes only a PostCSS config, use the PostCSS plugin. 3. If a webpack configuration is yours to edit, the webpack loader avoids a separate PostCSS step. 4. If there is no JavaScript bundler (server-rendered templates, a static site), use the CLI. The optimisation pass runs by default for production builds in the bundler integrations: the PostCSS plugin and the webpack loader expose an `optimize` option that defaults to on in production, and the CLI turns it on with `--minify` or `--optimize`. ## The browser floor Tailwind CSS v4 is **designed for and tested on Chrome 111, Safari 16.4 and Firefox 128**. The upgrade guide explains why: core framework features depend on modern CSS such as `@property` and `color-mix()`, and it advises projects that must support older browsers to stay on v3.4. Two details keep this honest: - The optimisation pass runs Lightning CSS against **those fixed targets**. v4 does not read a Browserslist query, so setting one does not move Tailwind's output, which is another reason a separate `autoprefixer` adds nothing for the CSS Tailwind processes. - Release **4.1.0** improved compatibility with older versions of Safari and Firefox, so "nothing renders below the floor" overstates it; still, no release promises support there. ## Mistakes when wiring an integration - **Keeping the v3 plugin list.** A config that still names `tailwindcss` as a PostCSS plugin fails in v4, because that package is no longer the plugin; `@tailwindcss/postcss` is. - **Leaving `autoprefixer` in place "to be safe".** It duplicates work Tailwind already does and does not widen browser support, because the floor comes from the CSS features v4 depends on, not from missing prefixes. - **Choosing by features.** All four integrations run the same compiler and scanner, so none unlocks utilities the others lack; choose by the build you have. - **Putting a preprocessor in front.** A Sass step before Tailwind duplicates the import and nesting work Tailwind does, and the documentation advises against it. ## Before adopting v4 - Check the product's browser-support policy against the floor above; it is the one constraint no configuration changes. - Pick the integration from the existing build, then remove `postcss-import`, `autoprefixer` and any preprocessor step from the path Tailwind's stylesheet takes. - Keep one `@import "tailwindcss";` entry stylesheet and let Tailwind bundle the rest of your CSS through ordinary `@import`s. - Confirm the minified production stylesheet comes from Tailwind's own optimisation pass, and drop any separate minifier or prefixer that duplicates it for that stylesheet.

  • A team wants to keep Sass in front of Tailwind v4 for variables and nesting. What do you tell them?
    That v4 is not designed to run behind a preprocessor. Tailwind already bundles imports and flattens nesting, and native CSS variables, which Tailwind relies on, cover what Sass variables did. The documentation compares it to running one preprocessor behind another: two tools doing the same job.
  • The product must still support Safari 15. Can it adopt Tailwind v4?
    Not safely. v4 is designed for and tested on Safari 16.4 and later, and core features depend on `@property` and `color-mix()`. The upgrade guide advises staying on v3.4 until the support policy changes. Release 4.1.0 improved behaviour in older Safari, but nothing is promised below the floor.
  • Does adding `autoprefixer` with a broad Browserslist query widen Tailwind v4's browser support?
    No. Prefixes do not supply missing features such as `@property` or `color-mix()`, which v4 depends on, and Tailwind's own optimisation pass uses fixed targets, not Browserslist. The extra plugin only duplicates work.

  • Keep autoprefixer after Tailwind v4 or no prefixes are added.
  • In v4 the tailwindcss package itself is still the PostCSS plugin.
  • postcss-import must run first or @import fails with Tailwind v4.
  • Tailwind v4 reads Browserslist to decide which browsers to support.
  • Each integration generates different utilities, so choose by feature set.

Assumes Tailwind CSS v4 (4.3.3); the PostCSS plugin moved to @tailwindcss/postcss in v4.0 and @tailwindcss/webpack arrived in 4.2.0.