metaskills / less-rails

:-1: :train: Less.js For Rails
http://github.com/metaskills/less-rails
MIT License
340 stars 133 forks source link

Solve Sprockets DEPRECATION WARNING #137

Closed brendon closed 7 years ago

brendon commented 7 years ago

I’m using Grease https://github.com/yasaichi/grease as a wrapper around LessTemplate and ImportProcessor and have also rejigged the loading process to make things compatible with Sprockets 2, 3 and 4.

Extra changes:

Closes: #122 Finally! :)

Thanks to https://github.com/metaskills/less-rails/pull/128 for inspiration @MustafaZain.

brendon commented 7 years ago

@simi, finally the test suite seems to be in order! Let me know if you need any more information about this. I think there's a large group of people hanging out for this fix :D

tdonia commented 7 years ago

this works for us (thank you, @brendon!) -- almost -- on Rails 5.0 because it eliminates Sprockets.register_engine '.less', LessTemplate in railties in this commit: https://github.com/brendon/less-rails/commit/f573927f2de15b611f797fb650cb95856ec71d95#diff-998c29126ad83cee99c229f1d43307b5L16

the one additional issue that we hit is the line above:

Sprockets::Engines #force autoloading errs with block in <class:Railtie>': uninitialized constant Sprockets::Engines (NameError)

brendon commented 7 years ago

Thanks for the feedback @tdonia :) I've pushed a change that should hopefully fix that. Let me know how it works on your end. I'll see how travis likes it also.

ali-anwar commented 7 years ago

Any update on this? Thank you.

brendon commented 7 years ago

Hi @simi, I've updated the test matrix and all the tests pass. I'm only testing for the latest version of jruby. Is that ok?

I've commented out the warnings line. It's handy to have there locally to uncomment because of the excessive therubyracer warnings. We should migrate away from that perhaps in another PR since I think the Rails team did the same.

I'll wait to hear from you on the bundle vs bundle install thing.

brendon commented 7 years ago

Hi @simi, any more comments before we finalise this? :)

drn commented 7 years ago

@simi Can we get this merged in? We just upgraded sprockets / rails and are running into these warnings. Happy to help make any changes, but it looks like the changes have been made and we're just waiting on a merge + release.

ubugnu commented 7 years ago

I've used the workaround: gem 'less-rails', github: 'brendon/less-rails', branch: 'fix-sprockets-loading' On rails 5. But less files are no longer compiled (I get a 'not found' myscript.less.css) The same configuration works with the default gem. Any idea on how to fix the problem?

brendon commented 7 years ago

Hi @ubugnu, thanks for reporting the error. If .less.css is a usual extension then the problem is that it wasn't added as a valid extension for Sprockets 3 that requires all extensions to be explicitly defined.

I've added the .less.css extension in there for now. Give it a try. Can others chime in on whether .less.css is a usual extension for less files in Rails?

brendon commented 7 years ago

100,000 🎉 :D

brendon commented 7 years ago

Can you ping when the gem is released? :)

simi commented 7 years ago

First of all I'm really sorry for being the break at this deprecation removal problem.

I would like to thanks all involved in this, mainly @brendon for crafting this PR and @drn for friendly email ping.

This is included in fresh 3.0 release.