gradle-tailwind is a plugin for the Gradle build manager for the TailwindCSS framework.
NOTE This Gradle plugin is currently in alpha, so some information listed here does not apply fully yet.
- Gradle 7.4+
- Tailwind 3.0.3+ (v4.x supported)
The plugin configuration is simple, just see the following section for the relevant DSL for your project:
First, add your plugin like so:
plugins {
id "com.hyeons-lab.tailwind" version "0.3.0"
}And configure your Tailwind application as desired, like so:
tailwind {
version = "4.1.0"
configPath = "src/main/resources" // Optional for v4; required for v3
input = "src/main/resources/tailwind/tailwind.css"
output = "src/main/resources/css/example.css"
}First, add your plugin like so:
plugins {
id("com.hyeons-lab.tailwind") version "0.3.0"
}And configure your Tailwind application as desired, like so:
- Gradle <8.1
tailwind { version.set("4.1.0") configPath.set("src/main/resources") // Optional for v4; required for v3 input.set("src/main/resources/tailwind/tailwind.css") output.set("src/main/resources/css/example.css") } - Gradle >8.1
tailwind { version = "4.1.0" configPath = "src/main/resources" // Optional for v4; required for v3 input = "src/main/resources/tailwind/tailwind.css" output = "src/main/resources/css/example.css" }
This plugin supports both Tailwind CSS v3 and v4.
Tailwind v4 uses a CSS-based configuration system instead of tailwind.config.js. When using v4:
- The
configPathproperty is optional - if not set or iftailwind.config.jsdoesn't exist, the plugin will use CSS-based configuration - Configure your theme directly in your CSS file using
@themeand other v4 directives - See the Tailwind v4 documentation for details on CSS-based configuration
Tailwind v3 uses JavaScript configuration:
- Set
configPathto the directory containing yourtailwind.config.js - The plugin will automatically use the config file if it exists
:tailwindDownload- Downloads the TailwindCSS binary for the configured version. Automatically runs before compile/init tasks if the binary is missing. Includes SHA256 checksum verification for security.:tailwindInit- Initialises thetailwind.config.jsfile (for Tailwind v3) with the input and output provided in the config.- Options:
--full- Initialize with a full configuration file that includes all default options--postcss- Initialize PostCSS configuration alongside Tailwind config--esm- Generate an ESM format configuration file--ts- Generate a TypeScript configuration file
- Options:
:tailwindCompile- Compiles the given Tailwind CSS file to the path provided inoutput. Automatically downloads the binary if needed.
There is a working example containing a rudimentary Tailwind project. To compile the CSS and view the HTML properly, run the following task:
./gradlew :example:tailwindCompileBecause Gradle sucks, the only LTS versions that this build allows for are 8 and 11, due to a known issue with the tests. The plugin itself should build with Java 17 in the meantime.
This project is licensed under the Apache 2.0 license.