RealFaviconGenerator / realfavicongenerator

Generate favicon for all major platforms
501 stars 24 forks source link

ActionView::Template::Error (The asset "favicon/site.webmanifest" is not present in the asset pipeline.) #497

Open simonsay opened 7 months ago

simonsay commented 7 months ago

Rails 7.1.3 on Ubuntu 20.04 LTS, nginx 1.18.0-0ubuntu1.4, libnginx-mod-http-passenger/focal,now 1:6.0.20-1~focal1 amd64 [installed] web_app_manifest.rb: Rails.application.config.assets.configure do |env| mime_type = 'application/manifest+json' extensions = ['.webmanifest']

if Sprockets::VERSION.to_i >= 4 extensions << '.webmanifest.erb'
env.register_preprocessor(mime_type, Sprockets::ERBProcessor) end

env.register_mime_type(mime_type, extensions: extensions) end

Runs ok on local machine with bin/dev, on server Processing by HighVoltage::PagesController#show as HTML Parameters: {"id"=>"home"} Rendered layout layouts/application.html.erb (Duration: 1.0ms | Allocations: 443) Completed 500 Internal Server Error in 2ms (ActiveRecord: 0.0ms | Allocations: 762)

ActionView::Template::Error (The asset "favicon/site.webmanifest" is not present in the asset pipeline.

1: <link rel="apple-touch-icon" sizes="180x180" href="<%= asset_path 'favicon/apple-touch-icon.png' %>">
2: <link rel="icon" type="image/png" sizes="32x32" href="<%= asset_path 'favicon/favicon-32x32.png' %>">
3: <link rel="icon" type="image/png" sizes="16x16" href="<%= asset_path 'favicon/favicon-16x16.png' %>">
4: <link rel="manifest" href="<%= asset_path 'favicon/site.webmanifest' %>">
5: <link rel="mask-icon" href="<%= asset_path 'favicon/safari-pinned-tab.svg' %>" color="#5bbad5">
6: <link rel="shortcut icon" href="<%= asset_path 'favicon/favicon.ico' %>">
 7: <meta name="apple-mobile-web-app-title" content="SteadiCamTony">

app/views/application/_favicon.html.erb:4 app/views/layouts/application.html.erb:9

_favicon.html.erb:

application.html.erb: <!DOCTYPE html>

SteadiCamTony <%= csrf_meta_tags %> <%= csp_meta_tag %> <%= render 'application/favicon' %> <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> <%= javascript_importmap_tags %> <%= image_tag('IMG_3718.png', width: 1834, height: 1372, id: "bgd") %> <%= yield %>
n-at-han-k commented 6 months ago

Please note that this issue is posted on the incorrect Repo. Correct one is: https://github.com/RealFaviconGenerator/rails_real_favicon

I’m answering this as I ended up here from google first. If you’re using Rails 7 then this issue is solved using the instructions here: https://github.com/RealFaviconGenerator/rails_real_favicon/issues/46

Delete the config/initializers/web_app_manifest.rb file and you should be good to go.

Or just comment it out

#Rails.application.config.assets.configure do |env|
  #mime_type = 'application/manifest+json'
  #extensions = ['.webmanifest']  

  #if Sprockets::VERSION.to_i >= 4
    #extensions << '.webmanifest.erb'    
    #env.register_preprocessor(mime_type, Sprockets::ERBProcessor)
  #end  

  #env.register_mime_type(mime_type, extensions: extensions)
#end
joaomarceloods commented 3 months ago

If you're using Rails 7 you also need to add these two to manifest.js:

//= link favicon/site.webmanifest
//= link favicon/browserconfig.xml