Zurb Foundation 5, modernizr not found

2020-08-21 01:34发布

I get this when using Foundation 5.0.2.0 in production mode.

On Rails, Unicorn, NginX & Ubuntu.

"NetworkError: 404 Not Found - http://mydomain.com/javascripts/vendor/modernizr.js"

6条回答
甜甜的少女心
2楼-- · 2020-08-21 02:11

There is an issue with the version of the foundation-rails gem you are using. In fact even the latest version currently available (5.0.3.1) has this problem. There is a pull request which claims to fix this: https://github.com/zurb/foundation-rails/pull/71 but another option for now is to update your gem to 5.0.3.1 and add this line to your production.rb file:

config.assets.precompile += %w( vendor/modernizr.js )
查看更多
forever°为你锁心
3楼-- · 2020-08-21 02:13

I am using foundation-rails (5.2.2.0) and I solved it by just adding:

//= require modernizr

below

//= require_tree .

in app/assets/javascripts/application.js

查看更多
女痞
4楼-- · 2020-08-21 02:19

I got the same error as you and I did this to fix it:

In config/environments/production.rb, set this:

# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = true
查看更多
迷人小祖宗
5楼-- · 2020-08-21 02:23

Update 3/13/14

I don't have this problem on heroku with foundation-rails-5.1.1.0. Adding javascript_include_tag "vendor/modernizr" in the head works. I could remove the modernizr I copied to the vendor directory and remove the extra line in app.js


I had the same problem on heroku, the app would crash because it couldn't find modernizr.js. Here's how I fixed it:

  • Copy modernizr.js from foundation (wherever you installed it with bundler) into vendor/assets/javascripts/.
  • Add //= require modernizr below //= require_tree . on application.js.
  • Remove javascript_include_tag "vendor/moderizr" from application.html
查看更多
一纸荒年 Trace。
6楼-- · 2020-08-21 02:28

Please follow the manual instructions from zurb here:

http://foundation.zurb.com/docs/applications.html

Which specifiy that the modernizr script be included inside the head tag. I ran into this issue and then fixed it using the following code in layouts/application.rb:

%head

  %title= title
  = stylesheet_link_tag    "application"
  = javascript_include_tag "vendor/modernizr"
  = csrf_meta_tags
  = favicon_link_tag
  = yield(:head)
查看更多
女痞
7楼-- · 2020-08-21 02:33

Try updating the gem you're using for Foundation. This commit from five days ago may help you since it claims to add a missing modernizr.js file.

查看更多
登录 后发表回答