使用Rails 3.1的资产管道预编译.scss清单文件

时间:2021-10-01 09:47:35

The release version of Rails 3.1 is having some weird issues with precompiling a sass manifest file with the extension scss. The weird thing is that the default manifest file application.scss compiles fine and I see it under public/assets/.

Rails 3.1的发布版本在使用扩展名scss预编译sass清单文件时遇到了一些奇怪的问题。奇怪的是默认的manifest文件应用程序。scss编译良好,我在public/assets/下看到它。

However when I try to compile my custom manifest files, nothing is created. I have enabled the precompile option in the production config.

但是,当我尝试编译自定义清单文件时,没有创建任何内容。我在产品配置中启用了预编译选项。

config.assets.precompile += %w( user.scss admin.scss )

I am running the precompile rake task correctly as far a I know.

就我所知,我正在正确地运行预编译rake任务。

rake assets:precompile RAILS_ENV=production

And maybe this helps. When I create two new manifest files with the extension css instead of scss and require the original scss files in them, then these new manifest files are honored and properly compiled. Why does application.scss get this special treatment and not other sass manifest files?

也许这可以帮助。当我用扩展css而不是scss创建两个新的manifest文件时,并且需要其中包含原始的scss文件,那么这些新的manifest文件就会得到确认并得到适当的编译。为什么应用程序。scss得到这种特殊处理而不是其他sass清单文件?

2 个解决方案

#1


27  

Include the compiled filenames in your precompile list:

在预编译列表中包含已编译的文件名:

config.assets.precompile += %w( user.css admin.css )

Also, you may want to to rename the original files in app/assets/stylesheets to include the compiled extension in the original filenames so it's clear what is going on:

此外,您可能想要重命名应用程序/资产/样式表中的原始文件,以便在原始文件名中包含已编译的扩展名,以便清楚地了解发生了什么:

user.scss -> user.css.scss
admin.scss -> admin.css.scss

#2


-2  

I suspect it might be bug.

我猜可能是虫子。

The application files are treated as the main files for a default project. The one ending in .css and .js are included in the precompile list by default.

应用程序文件被视为默认项目的主文件。默认情况下,在.css和.js中的结尾包含在预编译列表中。

The behavior you describe (manifests having a .css extension) is the correct one.

您所描述的行为(表示具有.css扩展)是正确的。

#1


27  

Include the compiled filenames in your precompile list:

在预编译列表中包含已编译的文件名:

config.assets.precompile += %w( user.css admin.css )

Also, you may want to to rename the original files in app/assets/stylesheets to include the compiled extension in the original filenames so it's clear what is going on:

此外,您可能想要重命名应用程序/资产/样式表中的原始文件,以便在原始文件名中包含已编译的扩展名,以便清楚地了解发生了什么:

user.scss -> user.css.scss
admin.scss -> admin.css.scss

#2


-2  

I suspect it might be bug.

我猜可能是虫子。

The application files are treated as the main files for a default project. The one ending in .css and .js are included in the precompile list by default.

应用程序文件被视为默认项目的主文件。默认情况下,在.css和.js中的结尾包含在预编译列表中。

The behavior you describe (manifests having a .css extension) is the correct one.

您所描述的行为(表示具有.css扩展)是正确的。