dartsass-rails
dartsass-rails copied to clipboard
Define constants in separate module
This avoids a constant redefinition warning if the build.rake
file is loaded twice (which, in our case, is more than annoying since we raise on warnings in development and test mode!)
Could you post the actual warning you avoiding with this?
Sure, in our case we are using the handcuffs gem to allow phased migrations, which I believe is calling Rails.application.load_tasks
a second time, which ends up looking something like this:
$ bin/rails db:test:load handcuffs:migrate[all]
/home/jma/.local/share/asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/dartsass-rails-0.5.0/lib/tasks/build.rake:1: warning: already initialized constant EXEC_PATH
/home/jma/.local/share/asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/dartsass-rails-0.5.0/lib/tasks/build.rake:1: warning: previous definition of EXEC_PATH was here
/home/jma/.local/share/asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/dartsass-rails-0.5.0/lib/tasks/build.rake:2: warning: already initialized constant CSS_LOAD_PATH
/home/jma/.local/share/asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/dartsass-rails-0.5.0/lib/tasks/build.rake:2: warning: previous definition of CSS_LOAD_PATH was here
/home/jma/.local/share/asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/dartsass-rails-0.5.0/lib/tasks/build.rake:3: warning: already initialized constant CSS_BUILD_PATH
/home/jma/.local/share/asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/dartsass-rails-0.5.0/lib/tasks/build.rake:3: warning: previous definition of CSS_BUILD_PATH was here
We're seeing the same warnings in a project I'm working on. Thanks for fixing this!
Sorry, needs a rebase.