node-gradle / gradle-node-plugin

Gradle plugin for integrating NodeJS in your build. :rocket:
Apache License 2.0
599 stars 117 forks source link

Bug: npx tailwindcss with args --watch #267

Open ArcSoul opened 1 year ago

ArcSoul commented 1 year ago

Description

Hi, I tried to execute the following task (go to reproduce the error for more details) and the problem is when I added --watch in args, when I add this command, it did not work, I don´t know why does this happens, Is there a bug when I execute some command with --watch like ng server --watch or similar? I tried to, execute Spring boot application and execute tailwind in parallel because I used thymeleaf.

Note: I clarify that the command does work if I remove the --watch, but I want the file to be pending changes

Reproduce error

     1 -- I made a task in build.gradle

tasks.register('frontend', NpxTask) {
    command = 'tailwindcss'
    ignoreExitValue = true

    inputs.files('package.json', 'package-lock.json', 'tailwind.config.js', 'postcss.config.js')
    inputs.files(fileTree('./src/main/resources/static'))
    inputs.files(fileTree('./src/main/resources/templates'))

    outputs.dir('./build/resources')

    dependsOn('npmInstall')
    args =  ['-i', './src/main/resources/static/css/tailwind.css', '-o', './src/main/resources/static/css/tailwind.min.css', '--watch']
}

     2 -- I run gradle frontend

     3 -- I saw to next response

22:02:28: Executing 'clean frontend'...

> Task :clean
> Task :nodeSetup UP-TO-DATE
> Task :npmSetup SKIPPED
> Task :npmInstall UP-TO-DATE
> Task :frontend

BUILD SUCCESSFUL in 1s
4 actionable tasks: 2 executed, 2 up-to-date
22:02:30: Execution finished 'clean frontend'.

Expected behavior

I expected to generate the file tailwind.min.js in /src/main/resources/static/css/tailwind.min.css.

deepy commented 1 year ago

Unfortunately I'm suffering through some dental issues so I might be a bit brief here, but just to make certain I'm not missing something: Are you trying to run Gradle with --watch or having a long-running Gradle process for bootRun while running another Gradle with the frontend task at the same time? (or a long-running Gradle process with both tasks, i.e. ./gradlew bootRun frontend and want it to continously run and re-deploy your frontend upon changes?)

It's kinda strange that it works without --watch but not with it. I'd expect it to work as you expect, or to run once ignoring the --watch, or to error out and give an error message

But personally when I've worked on frontends and backends separately I've always had a node start a dev server that watches for changes and redeploys the entire frontend while proxying all requests to the backend And then at the same time had JRebel or something else do hot reloads on the JVM-side. In fact, the Spring documentation has some mentions of hot-swapping and now I kinda wanna add another example build using that