开发者

Ignore file with CSS manifest?

I was wondering if there was a way to ignore a css file from being added to the manifest application.css file.

The reason why I want to do this is that I have two versions of the site, a mobile version, an an web version. The mobile version's css is currently being added to the manifest, and messing with the style of the main page.

Is there anyway to configure the manifest file to exclude 开发者_运维技巧a certain css file?


Remove the require_tree directive and add just the files you want, in the order you want them to application.css. Leave out the mobile CSS file.

To access the mobile CSS file you need to add it to the precompile list in production.rb:

config.assets.precompile += ['mobile.css']

This will allow you to use the standard rails helper to access the mobile css:

<%= stylesheet_link_tag "mobile" %>

as distinct from the application.css file.

One tip for these situations is that you can share CSS files between manifests. For example, if you have a CSS reset in a separate file this can be added to both manifests (assuming you make the mobile css a manifest too).


What I ended up doing was creating subdirectories under app/assets/stylesheets called app/assets/stylesheets/web and app/assets/stylesheets/mobile

Then place an application.css with the standard:

/* ...
*= require_self
*= require_tree .
*/

inside each of your new web and mobile folders. Then to access them:

# just use this

<%= stylesheet_link_tag    "web/application", :media => "all" %>

# or this as needed

<%= stylesheet_link_tag    "mobile/application", :media => "all" %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜