rails / tailwindcss-rails

MIT License
1.43k stars 175 forks source link

Allow the puma plugin to enable "debug" (no minification) #400

Open richardkmichael opened 2 months ago

richardkmichael commented 2 months ago

It would be helpful if the puma plugin could permit configuration of the TailwindCSS watcher in debug mode (to generate non-minified output). It seems this is only possible when starting the watcher using rake task (and therefore also a Procfile).

The Puma configuration DSL plugin does not accept arguments other than the plug-in name, so this can't be implemented as: plugin :tailwindcss, :debug.

It could be done with an environment variable . (The plug-in already uses environment for TAILWINDCSS_INSTALL_DIR.)

A simple patch:

# lib/puma/plugin/tailwindcss.rb

def start(launcher)
    debug = ["true", "1"].include? ENV["TAILWINDCSS_DEBUG"]
    # ...
        IO.popen(Tailwindcss::Commands.watch_command(debug: debug), 'r+') do |io|
    # ...
end
flavorjones commented 2 months ago

@richardkmichael Thanks for suggesting this addition. I'd prefer if we addded the environment variable logic to lib/tailwindcss/commands.rb, in the compile_command method.

Are you interested in putting together a PR for that? Ideally I'd also like a test added to test/lib/tailwindcss/commands_test.rb so we don't accidentally break it in the future. (And document it in the README!)