From app/javascript/packs/application.js
I'm trying to import "../foo"
where the file is foo.js.erb
. Webpacker and yarn are working great for other imports in application.js, for example import "../bar"
when that file is bar.js
but if I try with a .js.erb
file I get this error from webpack-dev-server:
ERROR in ./app/javascript/packs/application.js
Module not found: Error: Can't resolve '../foo' in '/Users/blah/backlot/projects/test/app/javascript/packs'
@ ./app/javascript/packs/application.js 3:0-27
@ multi (webpack)-dev-server/client?http://localhost:8080 ./app/javascript/packs/application.js
I do have rails-erb-loader installed and if I look at the webpacker config, the erb loader is being evaluated and looks right to me although I didn't touch any of that except for running rails webpacker:install
to generate that config.
config/webpack/paths.yml
butconfig/webpack/webpacker.yml
that must be updated. Confusingly, the list of extensions already contains- .erb
, but the extension to add is- .js.erb
. – Switzerland