Skip to content

wale/gradle-tailwind

Repository files navigation

Gradle Plugin Portal

gradle-tailwind

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.

How To Use

Requirements

  • Gradle 6+
  • Tailwind 3.0.3+

Plugin Configuration

The plugin configuration is simple, just see the following section for the relevant DSL for your project:

Groovy DSL

First, add your plugin like so:

plugins {
    id "au.id.wale.tailwind" version "0.2.0"
}

And configure your Tailwind application as desired, like so:

tailwind {
    version = "3.3.3"
    configPath = "src/main/resources"
    input = "src/main/resources/tailwind/tailwind.css"
    output = "src/main/resources/css/example.css"
}

Kotlin DSL

First, add your plugin like so:

plugins {
    id("au.id.wale.tailwind") version "0.1.0"
}

And configure your Tailwind application as desired, like so:

  • Gradle <8.1
    tailwind {
        version.set("3.3.3")
        configPath.set("src/main/resources")
        input.set("src/main/resources/tailwind/tailwind.css")
        output.set("src/main/resources/css/example.css")
    }
  • Gradle >8.1
    tailwind {
        version = "3.3.3"
        configPath = "src/main/resources"
        input = "src/main/resources/tailwind/tailwind.css"
        output = "src/main/resources/css/example.css"
    }

Available Tasks

  • :tailwindDownload - Downloads the TailwindCSS binary passed through from the config. Automatically run if the version or the cache folder cannot be found.(and on first run)
  • :tailwindInit - Initialises the tailwind.config.js file with the input and output provided in the config.
  • :tailwindCompile - Compiles the given Tailwind PostCSS file to the path provided in output.

Example

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:tailwindCompile

Development

Because 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.

License

This project is licensed under the Apache 2.0 license.

About

A TailwindCSS plugin for the Gradle build system.

Resources

License

Stars

Watchers

Forks

Packages

No packages published