简体   繁体   English

rails 4 asset_pipeline:包括供应商/资产的整个文件夹

[英]rails 4 asset_pipeline : Include whole folder for vendor/assets

The whole point of this is to include a template from wrap bootstrap. 这样做的全部目的是包括来自包装引导程序的模板。 I have been playing around with it, but would it be possible to include a folder to our rails application.css or application.js in app/assets (or even images). 我一直在玩,但有可能在应用程序/资产(甚至是图像)中包含一个文件夹到我们的rails application.css或application.js中。

I have put my files from my template under 我已将模板中的文件放在下面

  • vendor/assets/stylesheets/mytemplate/allmycssstuff 供应商/资产/样式表/ MyTemplate的/ allmycssstuff
  • vendor/assets/javascripts/mytemplate/allmyjavascriptsstuff 供应商/资产/ Java脚本/ MyTemplate的/ allmyjavascriptsstuff
  • vendor/assets/fonts/mytemplate/allmyfontsstuff 供应商/资产/字体/ MyTemplate的/ allmyfontsstuff
  • vendor/assets/images/mytemplate/allmyimagesstuff 供应商/资产/图像/ MyTemplate的/ allmyimagesstuff

For now , I basically require each one and it works, but it's a long process (since sometime templates have plugins). 就目前而言 ,我基本上都需要每个并且都可以,但是这是一个漫长的过程(因为有时模板具有插件)。 Is it possible to require a folder, so it fetch every file with *.css extension? 是否可能需要一个文件夹,以便它以* .css扩展名提取每个文件?

So, I would do something like (in app/assets/stylsheets/application.css): 因此,我会做一些类似的事情(在app / assets / stylsheets / application.css中):

*= require mytemplate/*.css (doesn't work)

And same for others... 和其他人一样...

You can use the require_tree directive in the application.css and application.js manifest files, which will recursively include any files in the given directories. 您可以在application.cssapplication.js清单文件中使用require_tree指令,这些指令将递归包括给定目录中的所有文件。 These are relative paths however, so you'll need something like this: 但是,这些是相对路径,因此您将需要以下内容:

 *= require_tree ../../../vendor/assets/stylesheets

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM