问题描述
我正在尝试将现有应用程序转换为新的 3.1 资产管道布局,并希望包含许多必须按特定顺序排列的供应商文件(underscore.js 和主干是一对).因此,我不能只使用 = require_tree .
来拉入我的供应商文件(而不用前缀重命名每个文件.糟糕).
以下内容在我的 app/assets/javascripts/application.js
文件中:
我已经尝试了带/不带扩展、带/不带 require_tree 和带/带相对路径的所有组合,但没有任何效果.我所有的供应商文件都在 /vendor/assets/javascripts/
中.
我觉得我很愚蠢,因为这似乎是一个如此明显的用例,(按名称按名称包含特定文件在 JS 中很常见,不是吗?)我一定是在做一些愚蠢的事情?
您可以按特定顺序要求每个文件,然后添加:
//= require_self
代替:
//= require_tree .
I am trying to convert an existing app to the new 3.1 asset pipeline layout, and want to include a lot of vendor files that have to be in a specific order, (underscore.js and backbone being one pair). As such, I can't just use a = require_tree .
to pull in my vendor files, (without renaming each file with a prefix. Yuck).
The following is within my app/assets/javascripts/application.js
file:
//= require modernizr-1.7 //= require jquery-1.6.1 //= require underscore-1.1.5 //= require backbone-0.3.3 //= require_tree .
I have tried every combination of with/out extensions, with/out the require_tree and with/out the relative paths, and nothing works. All of my vendor files are in /vendor/assets/javascripts/
.
I feel like I am being stupid because this seems like such an obvious use case, (including specific files by name in an order is common with JS, no?) that I must be doing something idiotic?
You can require each file in particular order and then add:
//= require_self
instead of:
//= require_tree .
这篇关于Rails 3.1 资产管道和手动排序的 Javascript 需要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!