为什么Rails资产管道在没有被称为“application.css.scss”时会编译CSS清单?(Why won't the Rails asset pipeline compile a

编程入门 行业动态 更新时间:2024-10-25 16:29:39
为什么Rails资产管道在没有被称为“application.css.scss”时会编译CSS清单?(Why won't the Rails asset pipeline compile a CSS manifest when it's not called “application.css.scss”?)

到目前为止,我的所有应用程序的CSS都通过application.css.scss ,如下所示:

/* ... *= require jquery-ui *= require_self *= require_tree . */ @import "bootstrap";

在调试时,我发现清单HAS被称为application.css

我错过了一些很好的机会。 但是,如果将问题解决回原来的问题,我只关注应用程序的样式表本身。

我发现当它被称为application.css.scss ,它被编译得很好但是当名称被更改时它没有得到处理:

这样可行:

application.html.haml

... = stylesheet_link_tag "application" ...

是什么让“application.css.scss”变得特别?

为什么会这样? 为什么我不能只使用任何旧名称的清单文件?

(如果它完全相关我正在部署到Heroku)

Up until now all of my application's CSS has been served through application.css.scss which looks like this:

/* ... *= require jquery-ui *= require_self *= require_tree . */ @import "bootstrap";

On debugging I discovered that the manifest HAS to be called application.css

There's a good chance I'm missing something. BUT on stripping the problem back to its bare essentials I looked just at the application's stylesheet itself.

What I found was that when it was called application.css.scss, it was compiled just fine but when the name was changed it didn't get processed:

So this works:

application.html.haml

... = stylesheet_link_tag "application" ...

What makes "application.css.scss" special?

Why is this going on? Why can't I just use a manifest file that has any old name?

(if it's at all relevant I'm deploying to Heroku)

最满意答案

如果要将样式表用作独立文件,则必须将样式表添加到预编译中。

# config/environments/production.rb # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. config.assets.precompile += %w(testing.css)

You have to add stylesheets to the precompilation if you want to use them as a standalone file.

# config/environments/production.rb # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. config.assets.precompile += %w(testing.css)

更多推荐

本文发布于:2023-08-06 17:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1454949.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:被称为   时会   清单   管道   资产

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!