How can I enable assets minifying in development environment?

897 views
Skip to first unread message

Rodrigo Rosenfeld Rosas

unread,
May 24, 2012, 12:30:02 PM5/24/12
to rubyonra...@googlegroups.com
I was trying an concept and found an weird issue when trying to enable
compression in my development environment.

I'd like to be able to run my specs on the minified versions as well,
so, using my rails_sandbox_jasmine gem, I'd like to use it this way:

SIMULATE_PRODUCTION=1 rake sandbox_assets:serve

And in my development.rb, I've set it to:

config.assets.js_compressor = :uglifier
config.assets.compress = !!ENV['SIMULATE_PRODUCTION']
config.assets.digest = !!ENV['SIMULATE_PRODUCTION']
config.assets.debug = !ENV['SIMULATE_PRODUCTION']

The debug (concatenation) and digest feature work but the generated
assets are not minified.

Is that expected?

Thanks in advance,
Rodrigo.

Simon de Boer

unread,
May 25, 2012, 8:57:16 AM5/25/12
to rubyonra...@googlegroups.com
It appears that you have to be explicit in specifying the files that get compiled.

config.assets.precompile += %(asset1.js asset2.js style1.css)

The default just contains application.(css|js)

Hopefully this assists you.

Rodrigo Rosenfeld Rosas

unread,
May 25, 2012, 10:24:35 AM5/25/12
to rubyonra...@googlegroups.com
Hi, Simon, thanks for your reply.

I guess you meant %w() instead of %(), right?

Indeed, the precompile options is required, but that alone won't make my application work.

I've tested in a fresh Rails application and the trick worked for it.

I'm investigating what could be causing this strange issue in my own application...

I'll let you know if I find some bug in any included gem...

Thanks,
Rodrigo.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/rPy5g41bdRUJ.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-co...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.

Rodrigo Rosenfeld Rosas

unread,
May 25, 2012, 11:21:45 AM5/25/12
to rubyonra...@googlegroups.com
I tried really hard to replicate the issue in a separate application for almost a full hour and I couldn't.

It only happens to one file and it doesn't happen if I rename it.

Since this seems to be an odd case instead of a general issue, I gave up on trying to identify it as I don't actually need to run my specs in minified versions of my assets and if I needed to it was just a matter of renaming the spec affected by this bug.

Also, for the record, it doesn't seem that config.assets.precompile option is required for this to work as my other assets were being minified even when not specified in the precompile option.

Cheers,
Rodrigo.
Reply all
Reply to author
Forward
0 new messages