使用Rails 3.1的资产管道预编译.scss清单文件 [英] Precompiling a .scss manifest file using Rails 3.1's asset pipeline

查看:57
本文介绍了使用Rails 3.1的资产管道预编译.scss清单文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Rails 3.1的发行版在预编译扩展名为scss的sass清单文件时遇到一些奇怪的问题.奇怪的是,默认清单文件application.scss可以正常编译,而我在public/assets/下看到它.

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

但是,当我尝试编译自定义清单文件时,什么也没有创建.我已经在生产配置中启用了预编译选项.

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 )

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

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

rake assets:precompile RAILS_ENV=production

也许这会有所帮助.当我创建两个扩展名为 css 而不是 scss 的清单文件并要求其中包含原始的scss文件时,这些新清单文件将受到尊重并进行了正确的编译.为什么application.scss得到这种特殊处理而不是其他sass清单文件?

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?

推荐答案

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

Include the compiled filenames in your precompile list:

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

此外,您可能想在app/assets/stylesheets中重命名原始文件,以将编译后的扩展名包含在原始文件名中,这样就可以清楚地知道发生了什么:

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

这篇关于使用Rails 3.1的资产管道预编译.scss清单文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆