foundation / foundation-rails

Foundation for Rails
foundation.zurb.com
MIT License
1k stars 375 forks source link

foundation-rails 6.3.1.0 breaks with Sprockets upgrade to 4.0.0 #294

Closed robjlucas closed 2 months ago

robjlucas commented 4 years ago

foundation-rails 6.3.1.0 breaks after upgrading Rails from 5.2.4.1 to 5.2.4.3, unable to find the main Foundation js file. Specifically, it is the upgrade of sprockets from 3.7.2 to 4.0.0 that causes this to break.

ActionView::Template::Error (couldn't find file 'foundation' with type 'application/javascript'
Checked in these paths: 
  /SomeProject/vendor/bundle/gems/babel-source-5.8.35/lib
  /SomeProject/app/assets/components
  /SomeProject/app/assets/config
  /SomeProject/app/assets/images
  /SomeProject/app/assets/javascripts
  /SomeProject/app/assets/stylesheets
  /SomeProject/vendor/assets/fonts
  /SomeProject/vendor/assets/javascripts
  /SomeProject/vendor/assets/stylesheets
  /SomeProject/vendor/bundle/gems/foundation_emails-2.2.1.0/vendor/assets/stylesheets
  /SomeProject/vendor/bundle/gems/chart-js-rails-0.1.6/vendor/assets/javascripts
  /SomeProject/vendor/bundle/gems/chartkick-3.3.0/vendor/assets/javascripts
  /SomeProject/vendor/bundle/gems/rails_sortable-1.2.1/vendor/assets/javascripts
  /SomeProject/vendor/bundle/gems/jquery-ui-rails-6.0.1/app/assets/images
  /SomeProject/vendor/bundle/gems/jquery-ui-rails-6.0.1/app/assets/javascripts
  /SomeProject/vendor/bundle/gems/jquery-ui-rails-6.0.1/app/assets/stylesheets
  /SomeProject/vendor/bundle/gems/foundation-rails-6.3.1.0/vendor/assets/_vendor
  /SomeProject/vendor/bundle/gems/foundation-rails-6.3.1.0/vendor/assets/js
  /SomeProject/vendor/bundle/gems/foundation-rails-6.3.1.0/vendor/assets/scss
  /SomeProject/vendor/bundle/gems/jquery-rails-4.3.3/vendor/assets/javascripts
  /SomeProject/vendor/bundle/gems/coffee-rails-4.2.2/lib/assets/javascripts
  /SomeProject/vendor/bundle/gems/actioncable-5.2.4.3/lib/assets/compiled
  /SomeProject/vendor/bundle/gems/activestorage-5.2.4.3/app/assets/javascripts
  /SomeProject/vendor/bundle/gems/actionview-5.2.4.3/lib/assets/compiled
  /SomeProject/vendor/bundle/gems/turbolinks-source-5.2.0/lib/assets/javascripts
  /SomeProject/app/assets/components
  /SomeProject/vendor/fonts
  /SomeProject/node_modules):

I'm sure it's something simple I'm missing, but several hours of searching and fiddling haven't brought it to light. There are various significant changes with the new version of Sprockets; though I don't see the immediate cause as yet.

app/assets/javascripts/application.js requires foundation as before, and as specified in the docs:

//= require jquery
//= require jquery_ujs
//= require jquery-ui/widgets/sortable
//= require rails_sortable
//= require foundation
//= require turbolinks
...

app/assets/config/manifest.js:

//= link_tree ../images
//= link application.js
//= link application.css
robjlucas commented 4 years ago

On further investigation I increasingly suspect this is something to do with ES6, but still don't have a solution.

joeworkman commented 4 years ago

This issue has been mentioned on Foundation Open Source Community. There might be relevant details there:

https://foundation.discourse.group/t/foundation-with-rails-and-sprockets-4/2692/1

DanielRuf commented 4 years ago

It looks like it misses some file extension. Can you provide a reproducible testcase as repository with the needed steps to run it?

robjlucas commented 4 years ago

It looks like it misses some file extension. Can you provide a reproducible testcase as repository with the needed steps to run it?

Thanks @DanielRuf. It'll take me a few days at least, but I'll do my best to do that asap.

frenkel commented 2 years ago

The problem seems to be that the .js.es6 file extensions used in this gem are not recognized by Sprockets. You can work around this error by creating an initializer: config/initializers/foundation-rails.rb with the following contents:

Sprockets.register_mime_type 'application/ecmascript-6', extensions: ['.es6', '.js.es6'], charset: :unicode