问题
I understand how to add one javascript file to rails assets pipeline. Just add
//= require filename
to application.js
But how can I include many javscripts files under one folder
vendor/assets/javascripts/<js_library>
Or I have to list them all explicitly ?
回答1:
//= require_tree .
will require everything in the current directory of your application.js
//= require_tree ./js_library
will require everything in the js_library
subdirectory if it is under app/assets/javascripts
If you are are trying to load javascripts under vendor/assets/javascripts, try:
//= require_tree ../../../vendor/assets/javascripts/js_library
来源:https://stackoverflow.com/questions/16226156/rails-include-javascripts-assets-folder-recursively