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
Only compile non-js/css under app/assets by default #7968
Only compile non-js/css under app/assets by default #7968
Conversation
I like the symmetry here, too. First thing I thought of. |
This makes sense to me 👍 On Oct 16, 2012, at 3:25 PM, Joshua Peek notifications@github.com wrote:
|
/cc @rafaelfranca |
Only compile non-js/css under app/assets by default
@josh could you add the CHANGELOG entry? |
When you say, "by hand," how does that work? Are you suggesting adding the For example, if I need to vendor a jQuery plugin which also has CSS, a font face, and an image sprite, I'd add the |
Document changes from #7968 in Upgrading Guide
This is a REALLY BAD change. Very confusing. Many css libraries have to tell their users to add a special line to their config/application.rb: config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif) |
This worked for me finally after wasting so many hours researching. config/application.rb
environment/production.rb Then I ran bundle exec rake assets:precompile RAILS_ENV=production and pushed it. |
If we're going for true parallelism, there ought to be a manifest file of sorts for images and fonts. Something just feels awkward about listing umpteen image and font paths in the app configuration. |
They load in development, but when you precompile them they aren't generated? The disparity between the different configurations (environments) shouldn't be there IMO. I'm fine with this change, but I think it should be symmetrical and behave in an understandable and consistent way. It's pretty clear by the issue being referenced on so many other issues that it's caused a considerable amount of confusion and issue churn. I'm happy to jump in and contribute to that if there's some consensus. |
@jejacks0n we are already on this rails/sprockets-rails#84 |
moved thumbnails to use deface to track better with spree_frontend updated gemspec to work with master branch tracking to 2-1-stable fixed single quote typo version bump Update _image.html.erb Update spree_product_zoom.gemspec use asset_path to point to the zoom image for assets precompile explicitly set the assets to include in precompile due to rails/rails#7968 start zoom gallery on selected image, display variant images too
I agree with @steveklabnik's sentiment at the top that the symmetry with lib/vendor in ruby code is nice, but AFAICT in practice this is actually quite dissimilar when you consider that merely "requiring" an asset isn't actually enough to get it copied over during That is to say, if I have a font in (I decided to just give in and start putting all non-CSS, non-JS 3rd party assets into |
This worked fine in dev and blew up in prod, thanks to this PR: rails/rails#7968 Leaving implementors to either list every vendor asset they want My comments here: rails/rails#7968 (comment)
This is an unfortunate opinion Rails has taken on this topic. This change has made it near impossible to use Bower to manage any front-end library that includes images or fonts (Bootstrap, jQuery-UI). The CSS and JavaScript work fine, but no matter how I configure my app, I cannot get the vendored images to end up where the CSS (relatively) expects they will be. Part of that is my doing, because I'm inlining the Boostrap CSS (into /assets/application.css) instead of serving it from it's "vendored" path of /assets/bootstrap/dist/css/bootstrap.css, but doesn't that defeat the purpose of Sprockets if I have to make all my vendored stylesheets separately precompiled packages? I don't know guys... this is one of the more maddening problems I've dealt with recently and I lost a lot of time on it because there is a TON of documentation about how to configure Bower to work with Rails... and those instructions just don't work or don't account for images and fonts included with Bower packages. As of now my options are 1) use gems for assets (which are often out of date) or 2) go back to manually cultivating the vendored assets. Blegh. |
@jcarlson I'm not sure how closely this PR relates to the problem you're describing. Anyway, suggestions for improvement are always welcome. |
Recent versions of Sprockets seem to be aware of |
because of rails/rails#7968, all files under app/assets/ are automatically compiled. this gets around the issue of files without extensions being included by sprockets.
With RAILS_ENV=development: With this change I get the expected error message of Sprockets::Rails::Helper::AssetNotPrecompiled if trying to do something like
in my view. This is assuming foo.js is in "vendor/assets/javascripts" This is also assuming I did NOT set the following:
However, I can still access the foo.js resource if not using a rails view helper. If I have something like
in my view helper. The weird thing is foo.js never appears in the public directory since it's not precompiled, yet it is still available accessing the url without a view helper. You would expect to not have the resource available. I only bring this up because it could give a developer a false sense of app stability. The app would fail to run in production because the foo.js resource would not be compiled. I've seen this problem happen more when requireJS is used without a javascript_path helper. The app would work in development, then fail in production when the resource could not be loaded. Even though this ticket is closed, hopefully I can get some feedback. I'll wait a week or so, and open a new ticket to get some thoughts. |
This has been bugging me forever.
I have a few packaged asset gems that have other loose files under their load path like README.mds. Those get copied over and digested to
public/assets
. This happens more often with bower packages.The other thing is that these libraries have many optional parts. You don't always want all the images and other stuff copied over unless you say so.
I'm suggesting that we only auto compile "loose" files under
app/asset
paths. This would include railtie gems. So if you doapp/assets
in your gem, those are auto included.lib/assets
andvendor/assets
are by hand. I think that this models Rails' default autoloading strategy ofapp/
is autoloaded and autorequired, whilelib/
andvendor/
have to be explicit.Depends on #7964 being merged first.
/cc @dhh