【发布时间】:2015-04-09 11:18:25
【问题描述】:
我想拥有一个包含不同 css、javascript 和图像文件的 onepager,用作我的应用程序的登录页面。
我将我的 css 移到了名为 onepager 的子文件夹下的 vendor/assets 文件夹中。我使用了一个子文件夹,因为我只会将这些文件用于 onepager 而不会用于其他任何东西。
例如
vendor/assets/stylesheets/onepager/
我创建了一个单独的布局,它引用了单独的 css 文件。 > onepager.html.erb
<%= stylesheet_link_tag 'onepager', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'onepager', 'data-turbolinks-track' => true %
在文件 onepager.js 和 onepager.css.scss 中,我希望它们引用 vendor/assets/xxx/onepager/ 文件夹中的文件。我添加了以下代码,但出现错误。
onepager.css.scss
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree ./onepager/
*/
onepager.js
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree ./onepager/
*/
我得到了要求树不是目录的错误?这很奇怪,因为它是一个目录,我假设供应商资产中的文件是自动加载的?
我该如何解决这个问题?
require_tree 参数必须是目录 (在/home/ubuntu/workspace/app/assets/stylesheets/onepager.css.scss:13)
【问题讨论】:
-
你用
ruby-on-rails、ruby-on-rails-3和ruby-on-rails-4标记了这个。你用的是哪个版本。请修正您的标签。
标签: ruby-on-rails asset-pipeline