sprockets duplicate file naming

孤街醉人 提交于 2019-12-10 21:19:49

问题


I have the following files, in my asset path:

javascripts/abc.js
templates/abc.js.mustache # this gets compiled to abc.js

naturally, they both would be requested as assets/abc.js.

Is there a fix? If not, what part of the Sprockets source would need to be modified?

My thinking is along the lines that if the engine can remove the extension, it can well enough add a suffix.


回答1:


It may be too obvious, but isn't it better just rename files? I understand nature of your question, but it's hard to imagine ultimate requirements, which forces same filenames for those files. Hence this, you have foobar.js and foobar.js.mustache, which compiles to foobar.js. Why they have same names? They do same things? This is design flaw, if you ask me.




回答2:


I have the same problem, and have not yet found a satisfying solution. My sites have many complex full-stack plugins (aka engines), and they have lots of css, js, and image files. Having to namespace, eg "styles.css" in each plugin kinda sucks. When upgrading to Rails 3, I assumed the file resolver would put engines/plugins in /styles, but no, they all get combined into one virtual path.

My current temporary solution is to build a rake task that I run that checks for duplicate filenames. I run it before committing code and on deployment. Hackity! If that helps, great, if not, perhaps someone out there has a more elegant solution...



来源:https://stackoverflow.com/questions/8024828/sprockets-duplicate-file-naming

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