I've just switched my Rails app over to use WebPack to deal with assets etc. It's working well apart from I have some JS templates in my views directory (*.js.erb) . These require jQuery and as jQuery is pulled in as part of my WebPack bundles, it is not working in those templates.
Is there a way to allow those templates to work?
I got this to work in my app by adding the expose-loader
package, then adding these two lines to my app/javascript/packs/application.js
:
import 'expose-loader?$!jquery';
import 'expose-loader?jQuery!jquery';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With