Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore paths to watch like node_modules #512

Closed
tom-spalding opened this issue Mar 15, 2025 · 4 comments
Closed

Ignore paths to watch like node_modules #512

tom-spalding opened this issue Mar 15, 2025 · 4 comments

Comments

@tom-spalding
Copy link

tom-spalding commented Mar 15, 2025

Hi is it possible to pass an ignore path param to the tailwindcss CLI? Long story short; I think it would be nice to ignore all node_modules directories.

More context:

The following is in my Procfile.dev, css: bin/rails tailwindcss:watch. My usecase is to avoid watching files in a large submodule. I have the common inotify_add_watch issue. Instead of bumping up my watchers every day like so

sudo vim /etc/sysctl.conf
sudo sysctl -p /etc/sysctl.conf

I think it would be nice to ignore all node_modules. Even without the large submodule issue, this seems like a common usecase I hope.

bin/dev
10:25:37 web.1  | started with pid 14116
10:25:37 css.1  | started with pid 14117
10:25:38 web.1  | => Booting Puma
10:25:38 web.1  | => Rails 8.0.2 application starting in development 
10:25:38 web.1  | => Run `bin/rails server --help` for more startup options
10:25:38 web.1  | Puma starting in single mode...
10:25:38 web.1  | * Puma version: 6.6.0 ("Return to Forever")
10:25:38 web.1  | * Ruby version: ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +YJIT +PRISM [x86_64-linux]
10:25:38 web.1  | *  Min threads: 3
10:25:38 web.1  | *  Max threads: 3
10:25:38 web.1  | *  Environment: development
10:25:38 web.1  | *          PID: 14116
10:25:38 web.1  | * Listening on http://127.0.0.1:3000
10:25:38 web.1  | * Listening on http://[::1]:3000
10:25:38 web.1  | Use Ctrl-C to stop
10:25:38 css.1  | sh: 1: watchman: not found
10:25:38 css.1  | error: inotify_add_watch on '/home/tom/projects/my_project/canvas/node_modules/@instructure/outcomes-ui/node_modules/@instructure/ui-flex/es/Flex/Item' failed: No space left on device
10:25:38 css.1  | 
10:25:38 css.1  | Bun v1.2.4 (Linux x64 baseline)
10:25:39 css.1  | exited with code 0
10:25:39 system | sending SIGTERM to all processes
10:25:39 web.1  | - Gracefully stopping, waiting for requests to finish
10:25:39 web.1  | Exiting
10:25:39 web.1  | terminated by SIGTERM

Thanks for the great project! - Tom

@tom-spalding
Copy link
Author

tom-spalding commented Mar 15, 2025

Awesome. It doesn't appear impossible. I'll try to do some debugging.

There is a --content param in the tailwindcss-ruby package. I'm hoping to use it in commands.rb like this in Procfile.dev: css: bin/rails tailwindcss:watch --content '!./**/node_modules'. Its dying with a SIGTERM but I'll keep debugging and report back. Have to figure out how to view the stack trace first 😆

update:

If don't run with Foreman, can see the error.

bin/rails tailwindcss:watch --content '!./**/node_modules'
# invalid option: --content

@flavorjones
Copy link
Member

@tom-spalding Hi, depending on whether you're running tailwind v3 or v4, the content parameter may not be supported. The README at tailwindcss-ruby shows the help contents from the v3 CLI, the v4 help contents are:

≈ tailwindcss v4.0.12

Usage:
  tailwindcss [--input input.css] [--output output.css] [--watch] [options…]

Options:
  -i, --input ··········· Input file
  -o, --output ·········· Output file [default: `-`]
  -w, --watch ··········· Watch for changes and rebuild as needed
  -m, --minify ·········· Optimize and minify the output
      --optimize ········ Optimize the output without minifying
      --cwd ············· The current working directory [default: `.`]
  -h, --help ············ Display usage information

and the v4 version has its own heuristics on what it chooses to pay attention to, please take a look at the docs at https://tailwindcss.com/docs/detecting-classes-in-source-files

What this all adds up to is, there's no good way to tell tailwind what not to watch. There was a related conversation on this topic in #491 and the brief summary is, the .gitignore file is supposed to be a way to control what gets ignored, but the tailwind "watch" command does not pay attention to this. The open upstream issue is tailwindlabs/tailwindcss#15684

I'm going to close this, since I don't believe there is anything this gem can easily to do change this behavior, but I'm happy to continue the conversation if you have questions.

@flavorjones flavorjones closed this as not planned Won't fix, can't repro, duplicate, stale Mar 15, 2025
@flavorjones
Copy link
Member

Side note: I've updated the README for tailwindcss-ruby to have the v4 help output.

@tom-spalding
Copy link
Author

Thanks @flavorjones, that's very helpful and makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants