Rails 5.1 webpacker "import" a .js.erb file?
To add Erb support in your JS templates, run
bundle exec rails webpacker:install:erb
on a Rails app already setup with Webpacker.
source (from cseelus' comment)
If what you want to do is this:
import '../foo'
When the actual file is foo.js.erb
, you need to update config/webpack/webpacker.yml
to include
- .js.erb
In the list of extensions. Otherwise you need to fully specify the file name you are importing
import '../foo.js.erb'