简体   繁体   中英

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).

I have put my files from my template under

  • vendor/assets/stylesheets/mytemplate/allmycssstuff
  • vendor/assets/javascripts/mytemplate/allmyjavascriptsstuff
  • vendor/assets/fonts/mytemplate/allmyfontsstuff
  • vendor/assets/images/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?

So, I would do something like (in 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. These are relative paths however, so you'll need something like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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