Skip to content

Fix config.assets.manifest Rake task and Railtie #136

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 4 commits into from
May 1, 2014

Conversation

johnnyshields
Copy link
Contributor

Currently, config.assets.manifest is not functioning as it should be. However, currently there no problem if config.assets.manifest is nil.

  • Fix assets:precompile Rake task. The Sprockets::Manifest object used in the Rake task is separate from the one created in the Railtie.
  • Fix config.assets.compile = false case. It is necessary to initialize the Sprockets::Manifest object with both the path to the assets, and the manifest path as parameters.
  • In Railtie initializer, rename internal variable manifest_path to manifest_assets_path for clarity, and revert its definition to what it was before PR Restore config.assets.manifest option #122
  • Add additional test cases related to config.assets.manifest option.

Proper functionality of the config.assets.manifest also requires this PR: sstephenson/sprockets#560. (Again, there is no issue if config.assets.manifest is left nil)

- fix Rake task
- fix config.assets.compile = false case
- add additional test cases related to config.assets.manifest option
@johnnyshields
Copy link
Contributor Author

Tests are failing pending next sprockets gem release, specifically this commit: sstephenson/sprockets@d52c9df

@@ -85,7 +85,7 @@ Defaults to `/assets`. Changes the directory to compile assets to.

**`config.assets.manifest`**

Defines the full path to be used for the asset precompiler's manifest file. Defaults to using the `config.assets.prefix` directory within the public folder.
Defines the full path to be used for the asset precompiler's manifest file. Must include filename. Defaults to using the `config.assets.prefix` directory within the public folder.
Copy link
Member

Choose a reason for hiding this comment

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

I think "full path [..] for [..] file" pretty much covers "must include filename". I think the bigger issue here remains: it doesn't actually default to that at all... it defaults to a randomly-generated filename inside the config.assets.prefix directory within the public folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shall I use the wording:

Defines the full path to be used for the asset precompiler's manifest file. Defaults to a randomly-generated filename in the config.assets.prefix directory within the public folder.

Copy link
Member

Choose a reason for hiding this comment

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

While it's not up to me.. I do feel that better addresses any suggestion that the option can point to a directory.

@rafaelfranca
Copy link
Member

@johnnyshields we will need to explicitly as @josh to backport that commit to 2.11.x release or we will not able to use in sprockets-rails 2.x. sprockets master is already sprockets 3.

@johnnyshields
Copy link
Contributor Author

@rafaelfranca the issue in Sprockets is that when user specifies a manifest file in a directory that does not yet exist, Sprockets raises an error (rather than creating the directory). I've raised a PR for the backport here: sstephenson/sprockets#561

Sprocket-Rails could be released without this backport (I can change the test case) but it may cause some users to scratch their heads if they haven't already created their manifest dir.

@johnnyshields
Copy link
Contributor Author

@rafaelfranca issue is resolved in Sprockets, @josh has pushed a new version, and tests are passing after pointing Sprockets-Rails gemspec to the new Sprockets version.

@rafaelfranca
Copy link
Member

New version is 2.12.1 and Rails applications are not able to use 2.12.x 😢 I can merge this one but people using sass-rails will still have to provide the full path with directories already existing.

@johnnyshields
Copy link
Contributor Author

OK I undid the sprockets dependency bump. CI tests are passing because existing gemspec references sprockets ~> 2.8, which evaluates to 2.12.1 for Travis purposes. Green-light to merge, no change for SASS users.

@johnnyshields
Copy link
Contributor Author

@rafaelfranca this PR is ready to merge.

@ryanjohns
Copy link

+1

@rafaelfranca, can this please be merged? I have a couple of projects that need this before I can upgrade to rails 4.1. Thanks

@seantanly
Copy link

+1

Same here. This is the main blocker that's preventing the projects that I have from adopting/upgrading to Rails 4.x

rafaelfranca added a commit that referenced this pull request May 1, 2014
Fix config.assets.manifest Rake task and Railtie
@rafaelfranca rafaelfranca merged commit 94a0332 into rails:master May 1, 2014
rafaelfranca added a commit that referenced this pull request May 1, 2014
Fix config.assets.manifest Rake task and Railtie
Conflicts:
	test/test_railtie.rb
@johnnyshields
Copy link
Contributor Author

@rafaelfranca thank you for merging.

To anyone upgrading, as a friendly reminder you'll need to set config.assets.manifest to include the manifest filename, e.g. Rails.root.join('config/manifest.json'). It cannot be a directory as done in Rails 3.2.

@seantanly
Copy link

Thank you @johnnyshields for creating the PR and @rafaelfranca for merging it.

For those who are using asset_sync gem, and uses the config.manifest = true option, Rails.application.config.assets.manifest being a file now will break asset_sync. You can check out a quick fix that I made. https://github.com/seantan/asset_sync/tree/filedetect-manifest

@johnnyshields johnnyshields deleted the fix-manifest-path branch August 2, 2014 21:44
@johnnyshields
Copy link
Contributor Author

FYI doc update for Rails Guides related to this is in rails/rails#16375

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants