Precompiling a .scss manifest file using Rails 3.1's asset pipeline

混江龙づ霸主 提交于 2019-11-30 13:43:20

问题


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 )

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

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?


回答1:


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:


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.

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



来源:https://stackoverflow.com/questions/7367864/precompiling-a-scss-manifest-file-using-rails-3-1s-asset-pipeline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!