tailwindcss/packages/@tailwindcss-webpack
Jiahan Chen 982e920df8
Add Rspack optional peer dependency for @tailwindcss/webpack (#20027)
## Summary

This PR makes Rspack support explicit for `@tailwindcss/webpack` by
adding `@rspack/core` as an optional peer dependency alongside
`webpack`.

The loader already works through Rspack's webpack-compatible loader API,
as shown in this runnable example:
https://github.com/rstackjs/rstack-examples/tree/main/rspack/tailwindcss.
The README and package description are updated to document that usage.

## Test plan

No Rspack-specific tests were added. The loader implementation is
unchanged, and the existing webpack loader tests exercise the same
loader API path that Rspack uses, which should cover the relevant
behavior.

---------

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2026-05-23 11:14:48 +02:00
..
src Fix webpack loader cache key for resource queries (#19723) 2026-03-20 16:34:11 +00:00
package.json Add Rspack optional peer dependency for @tailwindcss/webpack (#20027) 2026-05-23 11:14:48 +02:00
README.md update webpack readme to be a bit more consistent with other readmes 2026-02-20 12:04:41 +01:00
tsconfig.json Bump dependencies (#19957) 2026-04-24 21:21:12 +02:00
tsup.config.ts Add @tailwindcss/webpack loader for Tailwind CSS v4 (#19610) 2026-01-29 14:16:31 +00:00

Tailwind CSS

A utility-first CSS framework for rapidly building custom user interfaces.

Build Status Total Downloads Latest Release License


Documentation

For full documentation, visit tailwindcss.com.

Community

For help, discussion about best practices, or feature ideas:

Discuss Tailwind CSS on GitHub

Contributing

If you're interested in contributing to Tailwind CSS, please read our contributing docs before submitting a pull request.


@tailwindcss/webpack

A webpack loader for Tailwind CSS v4.

Installation

npm install @tailwindcss/webpack

Usage

// webpack.config.js
const MiniCssExtractPlugin = require('mini-css-extract-plugin')

module.exports = {
  plugins: [new MiniCssExtractPlugin()],
  module: {
    rules: [
      {
        test: /\.css$/i,
        use: [MiniCssExtractPlugin.loader, 'css-loader', '@tailwindcss/webpack'],
      },
    ],
  },
}

Then create a CSS file that imports Tailwind:

/* src/index.css */
@import 'tailwindcss';

Options

base

The base directory to scan for class candidates. Defaults to the current working directory.

{
  loader: '@tailwindcss/webpack',
  options: {
    base: process.cwd(),
  },
}

optimize

Whether to optimize and minify the output CSS. Defaults to true in production mode.

{
  loader: '@tailwindcss/webpack',
  options: {
    optimize: true, // or { minify: true }
  },
}