Rails include javascripts assets folder recursively

谁说胖子不能爱 提交于 2020-01-01 03:58:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!