Skip to content

Allow customizing input/output via env variables#577

Open
thewatts wants to merge 1 commit into
rails:mainfrom
thewatts:nw/input-output-env-vars
Open

Allow customizing input/output via env variables#577
thewatts wants to merge 1 commit into
rails:mainfrom
thewatts:nw/input-output-env-vars

Conversation

@thewatts
Copy link
Copy Markdown
Contributor

The Rails assets:precompile task internally calls bin/rails tailwindcss:build, which uses hardcoded input/output file paths. Previously, the only way to customize these paths was to bypass the Rails integration entirely and use the Tailwind CLI directly (via bundle exec tailwindcss).

This change introduces TAILWINDCSS_INPUT_FILE and TAILWINDCSS_OUTPUT_FILE environment variables that allow users to override the default paths while still using the standard assets:precompile workflow.

This is useful for projects with non-standard asset structures or when integrating with custom build pipelines.

The Rails `assets:precompile` task internally calls `bin/rails tailwindcss:build`,
which uses hardcoded input/output file paths. Previously, the only way to
customize these paths was to bypass the Rails integration entirely and use
the Tailwind CLI directly (via `bundle exec tailwindcss`).

This change introduces TAILWINDCSS_INPUT_FILE and TAILWINDCSS_OUTPUT_FILE
environment variables that allow users to override the default paths while
still using the standard `assets:precompile` workflow.

This is useful for projects with non-standard asset structures or when
integrating with custom build pipelines.
@thewatts thewatts force-pushed the nw/input-output-env-vars branch from be95b05 to be03a48 Compare August 30, 2025 00:12
@flavorjones
Copy link
Copy Markdown
Member

flavorjones commented Oct 27, 2025

Hi @thewatts, thanks for suggesting this change.

I'd like to understand the problem you're hoping to solve -- that is, why do you want to change these file names?

I'm asking questions because this implementation seems like it's only a partial solution that doesn't address the many places these paths are assumed after installation:

  • the .gitignore file
  • the experimental engine support feature
  • the clobber rake task
  • upgrade functionality (see lib/install/upgrade_tailwindcss.rb)

And I'm hoping that by understanding what problem is driving your contribution, that I can make some helpful suggestions. Thank you!

@manuelmeurer
Copy link
Copy Markdown

manuelmeurer commented Feb 28, 2026

Hi @flavorjones, I just found this PR, since I have the same wish as @thewatts to be able to customize the input and output file(s). 😄
My use-case is that my app has several "namespaces", which map to separate URLs and have separate styling.
Thus I'd like to have separate CSS files, one for each namespace, to allow for customizing TW and plugins, add custom CSS etc.

I understand that this is not a trivial change, since as you mentioned the default paths are assumed at different locations, but maybe it's worthwile adding this customization nevertheless?
For now, I'm using the TW CLI instead of the Rake tasks, but of course that's not optimal.

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

Successfully merging this pull request may close these issues.

3 participants