javascript Rails 递归地包含 javascripts 资产文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16226156/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Rails include javascripts assets folder recursively
提问by wwli
I understand how to add one javascript file to rails assets pipeline. Just add
我了解如何将一个 javascript 文件添加到 rails 资产管道。只需添加
//= require filename
to application.js
到 application.js
But how can I include many javscripts files under one folder
但是如何在一个文件夹下包含多个 javscripts 文件
vendor/assets/javascripts/<js_library>
Or I have to list them all explicitly ?
或者我必须明确列出它们?
回答by mccannf
//= require_tree .
will require everything in the current directory of your application.js
将需要 application.js 当前目录中的所有内容
//= require_tree ./js_library
will require everything in the js_library
subdirectory if it is under app/assets/javascripts
js_library
如果它在 app/assets/javascripts 下,将需要子目录中的所有内容
If you are are trying to load javascripts under vendor/assets/javascripts, try:
如果您尝试在 vendor/assets/javascripts 下加载 javascripts,请尝试:
//= require_tree ../../../vendor/assets/javascripts/js_library