Rails 3.1资产管道和手动订购的Javascript要求 [英] Rails 3.1 asset pipeline and manually ordered Javascript requires

查看:81
本文介绍了Rails 3.1资产管道和手动订购的Javascript要求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将现有应用程序转换为新的3.1资产管道布局,并希望包含许多必须按特定顺序排列的供应商文件(underscore.js和bone是一对).因此,我不能只使用= 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).

以下内容在我的app/assets/javascripts/application.js文件中:

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 .

我已经尝试了带有/不带有扩展名,带有/不带有require_tree以及带有/不带有相对路径的每种组合,但是没有任何效果.我所有的供应商文件都在/vendor/assets/javascripts/中.

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/.

我觉得自己很愚蠢,因为这似乎是一个显而易见的用例(按名称顺序包含特定文件在JS中很常见,不是吗?),我必须做些愚蠢的事情?

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

代替:

//= require_tree .

这篇关于Rails 3.1资产管道和手动订购的Javascript要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆