...
plugins {
...
// Gradle plugin for Node
id 'com.github.node-gradle.node' version '7.0.1'
}
...
// Necessary for node-gradle plugin
node {
download = true
}
// This task will run `tailwindcss` command and generate the output.css file from styles.css
tasks.register('tailwind', NpxTask) {
command = 'tailwindcss'
args = ['-i', './src/main/resources/static/styles.css', '-o', './src/main/resources/static/output.css']
// This task depends on npmInstall task
dependsOn(tasks.npmInstall)
}
// Make npmInstall task depend on npmSetup task and adds package.json as input
tasks.npmInstall {
inputs.file('package.json')
dependsOn(tasks.npmSetup)
}
tasks.withType(KotlinCompile).configureEach {
...
// Update the output.css file every time after compiling Kotlin code
dependsOn(tasks.tailwind)
}
...
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./src/**/*.{html,js}"],
}
{
"devDependencies": {
"@tailwindcss/forms": "^0.5.7",
"tailwindcss": "^3.3.6"
}
}