문제

How do I configure Middleman to build images without appending a hash to the filename? I'm referring to filepaths in javascript and need to know the full filename to refer to the files. My JS doesn't get updated with the hashed filenames like my CSS does.

도움이 되었습니까?

해결책

Oops, figured it out. I had enabled activate :asset_hash. removing that from config.rb fixed it.

다른 팁

No need to abandon :asset_hash just because you want to refer to them in JS. The asset hash extension actually attempts to rewrite paths in CSS and JavaScript automatically, but it sounds like whatever way you're linking them isn't getting detected.

You can always name your javascript something like application.js.erb and then have code like this:

var my_image = <%= image_path("myimage.png") %>;

That way you'll always have the right path.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top