Look up tailwind.config.js anywhere in the app directory (except dirs ignored explicitly) #204
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Problem
As discussed here: https://discord.com/channels/1082611227827638303/1254781033791098940 ,
tailwind.config.js
can show up in several places in a Rails app, based on how/when you installed Tailwind.However, the Phlex install generator currently assumes that
tailwind.config.js
should always be in theRails.root
directory. This can lead to some surprises if the user installing Phlex has the file somewhere else (config/tailwind.config.js
if installed with thetailwind-rails
generator, orapp/javascript/stylesheets/tailwind.config.js
for older (I'm guessing webpacker) apps; possibly other places, depending on your JS bundler config and whatnot).The Proposed Solution
This PR aims to rectify the situation by looking up the location of
tailwind.config.js
. Except some directories explicitly ignored by the generator (likenode_modules
,vendor
and such), it will look fortailwind.config.js
anywhere in the app directory.EDIT after @joeldrapper's review: It's cleaner and more maintainable to go with the whitelist approach ("look here: ... ") than the blacklist one ("look anywhere BUT here: ..."). Just keep in mind that your
tailwind.config.js
config has to be in either🤔
I'm assuming the previous implementation semantic was something like "If
tailwind.config.js
is not inRails.root
, this application is not using Tailwind, thus there's no need to apply any changes totailwind.config.js
, kthxbye".The current one is along the lines of "If you are using Tailwind, and you are not doing something extremely crazy (like having multiple
tailwind.config.js
files or storing them outside of the sensible directories (Rails.root
,app/**
,config/**
), we'll find the file and apply the modifications".