加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 解决Rails资产管道中依赖顺序的最佳方法?

发布时间:2020-12-17 02:34:47 所属栏目:百科 来源:网络整理
导读:我有一个RoR应用程序,它使用大量单独的.less文件来构建我的样式.我有一个master .less文件(config.less),其中包含其他文件使用的变量.我可以手动浏览每个子文件并添加@import语句,但我有很多,这似乎不是最好的方法.如果我使用* = require_tree,是否有设置某
我有一个RoR应用程序,它使用大量单独的.less文件来构建我的样式.我有一个master .less文件(config.less),其中包含其他文件使用的变量.我可以手动浏览每个子文件并添加@import语句,但我有很多,这似乎不是最好的方法.如果我使用* = require_tree,是否有设置某个订单的标准方法?

我试图在require_tree上面包含它

...
*= require 'less/config'
*= require_tree .

但我仍然在随后的.less文件中收到错误,抱怨它无法在config中找到值

variable @base is undefined
  (in /Users/me/project/app/assets/stylesheets/less/mixins.less)

解决方法

标准方法是不使用* = require_tree.并单独指定imports / require行.

从Rails Guide

Directives are processed top to bottom,but the order in which files are included by require_tree is unspecified. You should not rely on any particular order among those. If you need to ensure some particular JavaScript ends up above some other in the concatenated file,require the prerequisite file first in the manifest. Note that the family of require directives prevents files from being included twice in the output.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读