忽略带有 CSS 清单的文件?
我想知道是否有一种方法可以忽略添加到清单 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
删除 require_tree 指令并仅添加所需的文件,按照您希望它们添加到 application.css 的顺序。忽略移动 CSS 文件。
要访问移动CSS文件,您需要将其添加到预编译列表中
生产.rb
:这将允许您使用标准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
: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).
我最终做的是在
app/assets/stylesheets
下创建名为app/assets/stylesheets/web
和app/assets/stylesheets/mobile
的子目录>然后将具有标准:的 application.css 放置
在每个新的
web
和mobile
文件夹中。然后访问它们:What I ended up doing was creating subdirectories under
app/assets/stylesheets
calledapp/assets/stylesheets/web
andapp/assets/stylesheets/mobile
Then place an application.css with the standard:
inside each of your new
web
andmobile
folders. Then to access them: