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