我希望有一个包含不同css,javascript和图像文件的onepager,以用作我的应用程序的目标网页。
我将我的css移到了名为onepager的子文件夹下的vendor / assets文件夹中。我使用了一个子文件夹,因为我只会将这些文件用于onepager而不是其他任何文件。
e.g。
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树不是目录的错误?这很奇怪,因为它是一个目录,我假设供应商资产中的文件是自动加载的?
我该如何解决这个问题?
require_tree参数必须是目录 (在/home/ubuntu/workspace/app/assets/stylesheets/onepager.css.scss:13)
答案 0 :(得分:3)
自己找到答案。
我必须补充:
//= require_tree ../../../vendor/assets/javascripts/onepager
和css文件相同。之后,错误页面通知我使用它提供的代码更新config / initializers / assets.rb文件。
我现在在工作。