Skip to content

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

Closed
brandon-beacher wants to merge 1 commit intorails:masterfrom
brandon-beacher:master
Closed

Ensure precompile setting from app is applied to rake task.#36
brandon-beacher wants to merge 1 commit intorails:masterfrom
brandon-beacher:master

Conversation

@brandon-beacher
Copy link
Copy Markdown

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

* 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.
@josh
Copy link
Copy Markdown
Contributor

josh commented Jan 15, 2013

I think we want delegation over option copying.

👎

@brandon-beacher
Copy link
Copy Markdown
Author

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

@stevenharman
Copy link
Copy Markdown

@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
Copy link
Copy Markdown
Contributor

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
Copy link
Copy Markdown

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
Copy link
Copy Markdown
Author

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

@ai
Copy link
Copy Markdown

ai commented Feb 28, 2013

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

@senny
Copy link
Copy Markdown
Member

senny commented Mar 6, 2013

Link: rails/rails#9572

rafaelfranca referenced this pull request in rails/rails Mar 21, 2013
Document changes from #7968 in Upgrading Guide
@dhh
Copy link
Copy Markdown
Member

dhh commented Mar 29, 2013

@josh, is this good to go?

@guilleiguaran
Copy link
Copy Markdown
Member

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

@pointlessone
Copy link
Copy Markdown

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

@brandon-beacher
Copy link
Copy Markdown
Author

And precompiling in development is usually undesireable.

@btaitelb
Copy link
Copy Markdown

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
Copy link
Copy Markdown

soffes commented May 6, 2013

@btaitelb +1

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

@fphilipe
Copy link
Copy Markdown

Any updates on this?

@deneuxa
Copy link
Copy Markdown

deneuxa commented May 26, 2013

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

@eddiej
Copy link
Copy Markdown

eddiej commented May 28, 2013

Is there a workaround to this?

@fphilipe
Copy link
Copy Markdown

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

@guilleiguaran
Copy link
Copy Markdown
Member

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

@dhh
Copy link
Copy Markdown
Member

dhh commented Jun 3, 2013

Yes. But += used to work, I believe. It's a nasty gotcha.

On Jun 3, 2013, at 7:02 PM, Guillermo Iguaran notifications@github.com wrote:

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


Reply to this email directly or view it on GitHub.

@josh
Copy link
Copy Markdown
Contributor

josh commented Jun 3, 2013

#63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.