Frage

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.

War es hilfreich?

Lösung

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

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top