phlex-rails
phlex-rails copied to clipboard
Look up tailwind.config.js anywhere in the app directory (except dirs ignored explicitly)
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 the Rails.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 the tailwind-rails
generator, or app/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 (like node_modules
, vendor
and such), it will look fortailwind.config.js
anywhere in the app directory.
🤔
I'm assuming the previous implementation semantic was something like "If tailwind.config.js
is not in Rails.root
, this application is not using Tailwind, thus there's no need to apply any changes to tailwind.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 under one of the ignored directories, like .git
or node_modules
), we'll find the file and apply the modifications".