-
Notifications
You must be signed in to change notification settings - Fork 204
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
images and other assets #30
Comments
I'd suggest using EmberCLI for javascript only for now, and use conventional Rails Assets Pipeline for stylesheets and other assets including images. |
hmmmmmmmmmmmmmm |
what if I don't like the asset pipeline? 😛 There are many ember cli addons that bring in components with both js and css, how will these work? |
`¯_(ツ)_/¯ Any suggestions? We could investigate if it's possible to append public directories to Rails ActionDispatch::Static handler. |
you can use |
As far as images are concerned, I'm not sure what to do here. If you just throw them into the rails app they'd be availble but you'd not have the asset helpers in ember land |
right. ok I'll think more about this. I tend to like the frontend/backend separation when doing ember/rails apps, so this rubs me a bit the wrong way. But so far I'm liking the integration. I'll let you all know how it goes. Thanks for the work by the way, the project has a great api! |
Thanks! And thanks for tryin' it out. :)) [edit] Let us know if you have any thoughts on this btw. More eyes lookin' at it the better. |
@rwz Isn't the result of the build symlinked into the asset path of rails. If that is true then images should be served already. (will test as soon as I can, prolly not tonight) |
I believe that we need to change https://github.com/rwz/ember-cli-rails/blob/dec085b0a67c3ff05367ccc6b7384d148f6df23a/lib/ember-cli/app.rb#L127 to just symlink Does that make sense? |
Well, then the assets path's gonna be awkward, like |
True, but things would work ;) |
If you have an addon that adds things to the ember-cli its public tree, those assets will end up in For example: I have an addon that adds a It is also nice to have images in tldr; I think more things from the EmberCLI world will work out of the box, if the all of dist/ were available.... |
Now, I don't think just changing symlink from Alternative solution will be to keep assets pipeline the way it's now, but also attach |
@rwz - Setting the EmberCLI This is one way that folks deploy to S3 for example (just set the |
The baseURL could likely be set by the addon (and the path would be provided via an ENV var like the new |
What do you think of my mount-dist-to-public idea? |
Ya, mounting dist to public should be fine (and might also help the deployment situation). But if we do this, then why do we need to do both things (symlink |
I created PR #56 that may be worth looking at regarding this issue. It basically copies the contents of |
@chrisdevor I'm going to try to take some time tomorrow to look at #56 more closely. :) |
Sounds good. It should work with a stand alone |
Looks like broccoli-asset-rev has a built in |
Seems like setting baseURL would not be the right thing to do since that has other effects, no? |
Any advice on how to use |
Just want to contribute a problem scenario which we are facing currently. We are using the font-awesome addon: https://github.com/lfridael/ember-cli-font-awesome |
I had the same issue and ended up copying the fonts dir into app/assets/stylesheets. It works, but I'm sure it's not the recommended solution. |
@rainkinz ah, interesting fix for this particular problem. Thx. |
I have a hack, kind of works and would like to know if this is ok. First, in a helper for the Rails app say module ApplicationHelper
def image_assets
image_asset_dir = Rails.root.join('app', 'assets', 'images')
assets = {}
%w(.jpg .png .jpeg).each do |file_ext|
Dir.glob(File.join(image_asset_dir, "**", "*#{file_ext}")).each do |absolute_path|
file = absolute_path.sub(File.join(image_asset_dir, '/'), '')
assets[file] = asset_url(file)
end
end
assets
end
end with this defined, create this file <% environment.context_class.instance_eval { include ApplicationHelper } %>
window.assets = window.assets || {};
window.assets.images = <%= raw(image_assets.to_json) %>; now, assuming you have the normal <%= javascript_include_tag 'assets' %> Once you do this, you will have access to {{rails-asset-url 'logo.png'}} Since all the assets are in a .js.erb file, it is precompiled so the Dir.glob should have no impact in production. If this works, I think it shouldn't be too hard to roll into ember-cli-rails. :) What do you think? |
Initial steps toward closing [tricknotes/ember-cli-rails#30][#30]. * Prepend Sprockets path to EmberCLI assets. * Default fingerprinting to no generate `MD5` hash when building in `development`. [#30]: tricknotes/ember-cli-rails#30
Sweet! Thanks @seanpdoyle I'll test locally, then in a staging env and let you know how it goes. |
Initial steps toward closing [tricknotes/ember-cli-rails#30][#30]. * Prepend Sprockets path to EmberCLI assets. * Default fingerprinting to no generate `MD5` hash when building in `development`. [#30]: tricknotes/ember-cli-rails#30
Initial steps toward closing [tricknotes/ember-cli-rails#30][#30]. * Prepend Sprockets path to EmberCLI assets. * Default fingerprinting to no generate `MD5` hash when building in `development`. [#30]: tricknotes/ember-cli-rails#30
@Samsinite (and anyone else waiting on a fix): Any success with #30 (comment)? |
Initial steps toward closing [tricknotes/ember-cli-rails#30][#30]. * Prepend Sprockets path to EmberCLI assets. * Default fingerprinting to no generate `MD5` hash when building in `development`. [#30]: tricknotes/ember-cli-rails#30
Initial steps toward closing [tricknotes/ember-cli-rails#30][#30]. * Prepend Sprockets path to EmberCLI assets. * Default fingerprinting to no generate `MD5` hash when building in `development`. [#30]: tricknotes/ember-cli-rails#30
Initial steps toward closing [tricknotes/ember-cli-rails#30][#30]. * Prepend Sprockets path to EmberCLI assets. * Default fingerprinting to no generate `MD5` hash when building in `development`. [#30]: tricknotes/ember-cli-rails#30
Initial steps toward closing [tricknotes/ember-cli-rails#30][#30]. * Prepend Sprockets path to EmberCLI assets. * Default fingerprinting to no generate `MD5` hash when building in `development`. [#30]: tricknotes/ember-cli-rails#30
Initial steps toward closing [tricknotes/ember-cli-rails#30][#30]. * Prepend Sprockets path to EmberCLI assets. * Default fingerprinting to no generate `MD5` hash when building in `development`. [#30]: tricknotes/ember-cli-rails#30
Initial steps toward closing [tricknotes/ember-cli-rails#30][#30]. * Prepend Sprockets path to EmberCLI assets. * Default fingerprinting to no generate `MD5` hash when building in `development`. [#30]: tricknotes/ember-cli-rails#30
Initial steps toward closing [tricknotes/ember-cli-rails#30][#30]. * Prepend Sprockets path to EmberCLI assets. * Default fingerprinting to no generate `MD5` hash when building in `development`. [#30]: tricknotes/ember-cli-rails#30
Closes [#30]. Depends on [rondale-sc/ember-cli-rails-addon#17][#17]. * Symlink `dist/` directly to Asset Pipeline * Deletes `EmberCli::AssetResolver` * Improve `bin/setup`, resolve errors. [#30]: #30 [#17]: rondale-sc/ember-cli-rails-addon#17
Initial steps toward closing [tricknotes/ember-cli-rails#30][#30]. * Prepend Sprockets path to EmberCLI assets. * Default fingerprinting to no generate `MD5` hash when building in `development`. [#30]: tricknotes/ember-cli-rails#30
Closes [#30]. Depends on [rondale-sc/ember-cli-rails-addon#17][#17]. * Symlink `dist/` directly to Asset Pipeline * Deletes `EmberCli::AssetResolver` * Improve `bin/setup`, resolve errors. [#30]: #30 [#17]: rondale-sc/ember-cli-rails-addon#17
Initial steps toward closing [tricknotes/ember-cli-rails#30][#30]. * Prepend Sprockets path to EmberCLI assets. * Default fingerprinting to no generate `MD5` hash when building in `development`. [#30]: tricknotes/ember-cli-rails#30
@seanpdoyle thanks. i haven't had a chance to check it out, but it looks like you already got relevant testing and were able to merge? also, looks like your approach in #250 has rails-sprockets merge the broccoli-generated manifest during an asset build (similar to #181)? If so, then that's the core of the pull we were looking for. |
@skylar I ended up backing out of using the manifest. Didn't end up needing it. I've merged the Addon PR and the Gem PR into their respective masters, but I haven't released yet. I'd still love as much user-testing as possible, since I only have experience with a subset of the gem's use cases |
@seanpdoyle, there's a lot of information in this thread and I'm trying to get through it. I think I ran into an issue with adding the dist path to the asset pipeline: this doesn't work when we are skipping the asset pipeline, as in an nginx, self-hosted assets situation. I haven't dug very deeply, yet, but in production, the pipeline isn't running at all, so adding the dist directory does not work. Will probably solve, for now, by writing a task that loops through and copies the assets from dist to deploy. |
@kayakyakr I'm not sure of your particular use case, but as of In what ways doesn't |
Sorry, that was the older stuff. So serving stuff via Rack::File is great when you're using the rack server to serve assets. If assets are being served directly via nginx or in some other form, they will need to be copied to assets on deploy. I wrote a deploy task to link the assets in the ember build to the public assets folder: after "deploy:compile_assets", :ember_assets do
on roles :web do
execute :ln, '-sf', "#{release_path}/tmp/ember-cli/apps/home/assets/*", "#{release_path}/public/assets/"
end
end |
@kayakyakr I see. That capistrano task looks good to me, although it depends on I recommend serving the Ember assets over a CDN, since it relies on EmberCLI's public API, and isn't dependent on the underlying (private) directory structure. |
Eventually, but we're not ready to publish to a CDN, so I'll have to hack it for now. |
@seanpdoyle I finally had a chance to checkout your latest build. The code looks great! Better yet, I was able to migrate from 0.3.x to 0.7.x without too much of a fuss. Given the nature of our app, we have to handle at least 25% of our routes in rails (eg, custom controller/actions) when bootstrapping the ember app. (The others are just pass-throughs to 1 of 2 standard ember-app renders). What this means is that There are a couple of asset bugs to sort through, but nothing major. It seems the issues from this PR are more or less handled for me too. That said, I was wondering, do you see any specific issues for "legacy" ember-cli-rails apps that call |
@skylar you can see # Clobbers all /api/* routes, Keep this as the second to last route in the routes file
match '/api/*path', to: 'ember_application#api_not_found', via: :all So our route looks something like this: # other routes and stuff...
# Clobbers all /api/* routes, Keep this as the second to last route in the routes file
match '/api/*path', to: 'ember_application#api_not_found', via: :all
# Mount the ember app
mount_ember_app :frontend, to: "/", controller: 'ember_application' Our controller looks like this: class EmberApplicationController < EmberCli::EmberController
skip_before_action :authenticate
def api_not_found
render status: 404, nothing: true
end
end Here is an example template with extra stuff: <%= render_ember_app ember_app do |head, body| %>
<% head.append do %>
<%= csrf_meta_tags %>
<% end %>
<% body.append do %>
<% if Rails.application.secrets.server_status == 'development' %>
<div id="pipeline-flag">
<div class="development-flag">
<p>Development</p>
</div>
</div>
<% end %>
<% if Rails.application.secrets.server_status == 'staging' %>
<div id="pipeline-flag">
<div class="staging-flag">
<p>Staging</p>
</div>
</div>
<% end %>
<% end %>
<% end %> Really, this gem is much more flexible and awesome with the latest set of updates. We also keep using a proxy, with |
where should we put assets? I have an image in my ember cli app's
public
folder, but it's not showing up in the rails app.The text was updated successfully, but these errors were encountered: