Open aar0nTw opened 9 years ago
@aar0nTw Could you add a js_compressor
attribute to Requirejs::Rails::Config
and use that?
Hi @carsomyr:
It already has optimize
option for r.js build in build_config_whitelist
, we can use optimize: uglify2
and set more option for detail build output in requirejs.yml
.
I think it has no need to add attribute in requirejs rails config, We just need get the current sprocket compressor object, because the prepare_source
task is call sprockets to get assets path and write it to requirejs source path for r.js build, so it temporarily disable the compress function of sprockets and restore it after the task end.
@aar0nTw My main concern is clarity: The code in the Rake tasks refers to requirejs.config
, so an effort should be made to adhere to that.
@carsomyr updated, please check it
Can we get this merged?
@agis- Ok, I'll take a look at this again.
Run into the same issue too, using requirejs-rails 1.9.5, rails 4.2, sprockets 2.12.4 and sprockets-rails.
@aar0nTw Are you using this patch in production?
Also interested in this (requirejs-rails-0.9.9 / rails 4.2).
When I set
config.assets.js_compressor
to compressor with some custom options likeUglifier.new(mangle: false)
The precompile task always get the error:
Sprockets::Error: unknown compressor: js_compressor
, there's because Sprocket::Environment will return:js_compressor
symbol when we want to getRails.application.assets.js_compressor
value if user set compressor to specific compressor object , please see https://github.com/sstephenson/sprockets/blob/master/lib/sprockets/compressing.rb#L60and when the task want to put
orignal_js_compressor
back toenv.js_compressor
, Sprocket can't find any compressor source name:js_compressor
and throw error.So it should be cache the
Rails.application.config.assets.js_compressor
(A real compressor object) tooriginal_js_compressor
notRails.application.assets.js_compressor
.ref #201