How to access images in rudder templates if images are optimized using grunt-contrib-imagemin

I created an ember application with yoman and an ember generator.

yo ember 

I placed my steering patterns in the app / templates and images in the app / images. if i run

 grunt server 

everything looks great. If I run

 grunt server:dist 

everything looks great, not the images that I addressed in my steering patterns. It seems that the imagemin task or something else is renaming images from something like images / map.jpg to something like images /667de70e.map.jpg. Img tags fixed in my index.html file. But the img tags in my handlebars files, such as templates / map.hbs, still refer to the old images of the /map.jpg path.

How can I fix the path problem in my handlebars files? Is there an assistant?

+6
source share
2 answers

This is due to the rev task defined in Gruntfile.js . Do not think this is a simple solution for this at the moment, so I just comment out the line for renaming the images:

 // Gruntfile.js // ... rev: { dist: { files: { src: [ '<%= yeoman.dist %>/scripts/{,*/}*.js', '<%= yeoman.dist %>/styles/{,*/}*.css', // '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp}', '<%= yeoman.dist %>/styles/fonts/*' ] } } } 
+2
source

The best explanation I found here: fooobar.com/questions/944606 / ...

In short, the runt revunt task works as expected for css images, but not for img src attr.

+1
source

Source: https://habr.com/ru/post/944605/


All Articles