忽略带有 CSS 清单的文件?

发布于 2024-12-06 14:15:39 字数 161 浏览 0 评论 0原文

我想知道是否有一种方法可以忽略添加到清单 application.css 文件中的 css 文件。

我想这样做的原因是我有两个版本的网站,一个移动版本,一个网络版本。移动版本的 css 目前已添加到清单中,并扰乱了主页的样式。

是否有办法配置清单文件以排除某个 css 文件?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

残疾 2024-12-13 14:15:39

删除 require_tree 指令并仅添加所需的文件,按照您希望它们添加到 application.css 的顺序。忽略移动 CSS 文件。

要访问移动CSS文件,您需要将其添加到预编译列表中
生产.rb

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

这将允许您使用标准rails助手来访问移动CSS:


<%= stylesheet_link_tag "移动" %>

与 application.css 文件不同。

对于这些情况,一个技巧是您可以在清单之间共享 CSS 文件。例如,如果您在单独的文件中重置了 CSS,则可以将其添加到两个清单中(假设您也将移动 CSS 设为清单)。

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

空城仅有旧梦在 2024-12-13 14:15:39

我最终做的是在 app/assets/stylesheets 下创建名为 app/assets/stylesheets/webapp/assets/stylesheets/mobile 的子目录>

然后将具有标准:的 application.css 放置

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

在每个新的 webmobile 文件夹中。然后访问它们:

# just use this

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

# or this as needed

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

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" %>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文