从app/javascript/packs/application.js
我试图到import "../foo"
文件所在的位置foo.js.erb
。Webpacker 和 yarn 对于 application.js 中的其他导入非常有效,例如import "../bar"
当该文件是bar.js
但如果我尝试使用.js.erb
文件时,我会从 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
rails webpacker:install
我确实安装了 rails-erb-loader 并且如果我查看 webpacker 配置,erb 加载器正在被评估并且看起来对我来说是正确的,尽管除了运行以生成该配置之外我没有触及任何东西。