Skip to content

Ensure precompile setting from app is applied to rake task. #36

Closed
wants to merge 1 commit into from
@brandon-beacher

I was not able to use the precompile setting to solve the situation described here:

#34

This is due to the details below:

Rails calls load_tasks prior to the app's configure block.
This results in the sprockets rake task being initialized without the app's assets.precompile setting.

This change lazily evaluates the assets setting on the sprockets rake task so they will reflect the eventual assets.precompile setting.

With this change, loose assets in lib or vendor from a legacy gem will now be picked up if they are explicitly specified in the precompile setting.

This is dependent upon sstephenson/sprockets#404

@brandon-beacher brandon-beacher Ensure precompile setting from app is applied to rake task.
* Rails calls `load_tasks` prior to the app's configure block.
* This results in the sprockets rake task being initialized without the app's assets.precompile setting.
* This change lazily evaluates the assets setting in the rake task so it will reflect the eventual configuration of assets.precompile.
b11e44d
@josh
Ruby on Rails member
josh commented Jan 15, 2013

I think we want delegation over option copying.

👎

@brandon-beacher

Left a comment on this here sstephenson/sprockets#404 (comment)

@stevenharman

@josh Could you expand a bit on what you mean by "delegation over option copying" here? Are you suggesting that the Rake task should directly delegate to Rails.application.config.assets.precompile, rather than copying those settings over in the Sprockets::Rails::Task definition block?

The issue @brandon-beacher brings up results in not being able to vendor and automatically precompile things like images nor fonts in production - which seems broken to me.

@josh
Ruby on Rails member
josh commented Feb 18, 2013

Sprockets::Rails::Task can hold a reference to app.config. That way we don't need to worry about future initializers running after the copy step.

@alainmeier

Does somebody have this, or should I manually apply sstephenson/sprockets#404 and #35 for my own app?

Currently this is a rails 4 upgrade game breaker for anybody who uses multiple folders within their stylesheet asset folder (because you have to manually tell it to compile certain files)

@brandon-beacher

@alainmeier we've just been manually copying the loose assets from third party gems into app/assets by hand for now...

@ai
ai commented Feb 28, 2013

Rails team released Rails 4 beta, but Sprockets is still broken.

@senny
Ruby on Rails member
senny commented Mar 6, 2013
@dhh
Ruby on Rails member
dhh commented Mar 29, 2013

@josh, is this good to go?

@guilleiguaran
Ruby on Rails member

iirc, this work correctly setting config.assets.precompile in config/application.rb, right?

@pointlessone

@guilleiguaran Right. But still it seems Rails recommends to set this things on per-environment basis. And that doesn't work.

@brandon-beacher

And precompiling in development is usually undesireable.

@btaitelb

What's preventing this from getting accepted? It seems like several people are running into the issue of trying to configure assets in an environment-specific configuration file, which silently fails. I'm in favor of this approach as a short-term solution, with the goal that a more ideal long-term solution would fit better into the asset pipeline (without needing lazy evaluation).

@soffes
soffes commented May 6, 2013

@btaitelb +1

The Rails generator puts config.assets.precompile += ... in production.rb which doesn't actually work.

@fphilipe

Any updates on this?

@deneuxa
deneuxa commented May 26, 2013

config.assets.precompile += ... doesn't work for me either on production ...

@eddiej
eddiej commented May 28, 2013

Is there a workaround to this?

@fphilipe

@eddiej move the setting to application.rb where it will get picked up.

@amir20 amir20 referenced this pull request in zurb/foundation-sites Jun 2, 2013
Closed

vendor/custom.modernizr not working in rails 4 #2496

@guilleiguaran
Ruby on Rails member

config.assets.precompile << is working, right?

@dhh
Ruby on Rails member
dhh commented Jun 3, 2013
@josh
Ruby on Rails member
josh commented Jun 3, 2013

#63

@josh josh closed this Jun 3, 2013
@kostia kostia referenced this pull request in kostia/jquery-minicolors-rails Feb 8, 2014
Closed

jquery.minicolors.png is not compiled as assets on staging/production env #8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.