Question

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.

Était-ce utile?

La solution

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

Autres conseils

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top