Skip to content

Always initialize assets environment in rake task #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 6, 2015
Merged

Conversation

josh
Copy link
Contributor

@josh josh commented Feb 3, 2015

#220 causes a slight regression but brings up this weird issue again.

If config.assets.compile = false in production.rb than you can't even do rake assets:precompile.

This is a little work around to force the environment to build even in this case.

@rafaelfranca the environment weirdness between rake assets:precompile has always bugged me. Given 3.x can have backwards incompatible changes, have any idea for directions we can move into to make this more clear?

I really wish rake assets:precompile would work no matter what and always minified the assets even in RAILS_ENV=development. Would like to make it easier for people who compile assets in an isolate environment and upload them to a CDN. This sometimes happens locally on there machine and othertimes in production like environments that might not have a db.

@rafaelfranca
Copy link
Member

I really wish rake assets:precompile would work no matter what and always minified the assets even in RAILS_ENV=development.

Yeah, I'd like too but there are some configuration that still changes between environment like the assets prefix and the assets host. I don't have any idea on how change this to not use environment information.

@josh
Copy link
Contributor Author

josh commented Feb 4, 2015

Yeah, I dunno either :/

I think at least this compile direction will at least allow rake assets:precompile to do something.

The other issue I'm still worried about is building against an uninitialized app. Is there any flag thats set after initialize! is called? It'd be nice to check app.initialized? (maybe that already works) then maybe print a warning saying, hey, you attempted to compile assets against an non-initialized app, some settings might be wrong, etc.

@rafaelfranca
Copy link
Member

It'd be nice to check app.initialized? (maybe that already works) then maybe print a warning saying, hey, you attempted to compile assets against an non-initialized app, some settings might be wrong, etc.

Yeah, initialized? already exists, and a warning would be great.

@josh
Copy link
Contributor Author

josh commented Feb 5, 2015

Yeah, initialized? already exists, and a warning would be great.

Bah, so app.initialized? does work but app.initialized? == false inside the config.after_initialize block.

@@ -69,7 +69,11 @@ def configure(&block)
Sprockets::Rails::Task.new(app)
end

def self.build_environment(app)
def build_environment(app, initialized: app.initialized?)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little hacky, just allowing the after_init callback to skip the warning.

josh added a commit that referenced this pull request Feb 6, 2015
Always initialize assets environment in rake task
@josh josh merged commit 02b0153 into master Feb 6, 2015
@josh josh deleted the test-tasks branch February 6, 2015 06:53
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.

2 participants