Sprockets unable to find .es6 file upgrading from rails 4.2 to rails 5.0

Viewed 615

I am upgrading rails from 4.2 to 5.0 When I run the server I get the error:

Sprockets::FileNotFound in Companies::Overviews#index

couldn't find file 'common.source-dcede919e0ca241c0d16d2f91b57781b1804c7be230d659517ab562aa80e136c.source.es6'
Checked in these paths: 
[...]
/Users/Mari/TimePoints/app/assets/javascripts   //<--common.es is here
[...]

The error is coming index.html.erb from the line:

<%= javascript_include_tag "application" %>

In my application.js:

//=require common

Gemfile:

gem 'sprockets-rails', :require => 'sprockets/railtie'
gem 'sprockets', "~> 4.0.0.beta5"
gem 'babel-transpiler', '~> 0.7.0'

In config/initializers/assets.rb:

Rails.application.config.assets.precompile += %w( .svg .eot .woff .ttf .es6)

Nothing changed if I try adding the file explicitly as:

Rails.application.config.assets.precompile += %w( common.es6 ) 

I have tried adding in manifest.js the following but nothing changes:

 //= link_tree ../javascripts/ .es6
 //= link_directory ../javascripts/ .es6
 //= link common.es6

If I remove common.es6 from application.js then I get the same error with the next file in line cookies.es6

It seems that only the .es6 files have the problem. Not the .js nor the .css

1 Answers

For anyone else having this issue, the crux is specifying the file format that you "want" in the end, which is "js"; and not the one which file "has" in the file system. That is why Sprockets 4 documentation suggests to use css and js formats in manifest files, even though underlying files could be es6, scss etc. Hope it helps, anyone else stumbling upon this issue now or in future. Thanks!

Related