Skip to content

404 on images in heroku, usemin doesn't updated revved images in html partials #802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
leonardoanalista opened this issue Jan 29, 2015 · 7 comments

Comments

@leonardoanalista
Copy link

Hey all

First of all a big thanks for the great work on this full stack generator!

I noticed usemin and imagemin update the image only for index.html.
If you have any other html partial file, html remains the same and image is revved.

Steps to reproduce:

1 - add image to /client/app/main/main.html file:
<img src="assets/images/yeoman.png" alt="I'm Yeoman">

2 - run: grunt build

3 - deploy to heroku.

Image won't be found as now is called something else like: assets/images/ea0fda4e.yeoman.png

If you add the same image to index.html, Image-min does the right thing and updates the image name on index.html so no 404.

Here is my relevant config on Gruntfile:

    // Renames files for browser caching purposes
    rev: {
      dist: {
        files: {
          src: [
            '<%= yeoman.dist %>/public/{,*/}*.js',
            '<%= yeoman.dist %>/public/{,*/}*.css',
            '<%= yeoman.dist %>/public/assets/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= yeoman.dist %>/public/assets/fonts/*'
          ]
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      html: ['<%= yeoman.client %>/index.html'],
      options: {
        dest: '<%= yeoman.dist %>/public'
      }
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
      html: ['<%= yeoman.dist %>/public/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/public/{,*/}*.css'],
      // js: ['<%= yeoman.dist %>/public/{,*/}*.js', '!<%= yeoman.dist %>/public/app/templates-*.js'],
      js: ['<%= yeoman.dist %>/public/{,*/}*.js'],
      options: {
        assetsDirs: [
          '<%= yeoman.dist %>/public',
          '<%= yeoman.dist %>/public/assets/images'
        ],
        // This is so we update image references in our ng-templates
        patterns: {
          js: [
            [/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images']
          ]
        }
      }
    },

    // The following *-min tasks produce minified files in the dist folder
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.client %>/assets/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/public/assets/images'
        }]
      }
    },

cheers
Leonardo

@leonardoanalista leonardoanalista changed the title 404 on images in heroku, image-min doesn't updated revved images in html partials 404 on images in heroku, usemin doesn't updated revved images in html partials Jan 29, 2015
@harrisrobin
Copy link

+1

@MarkPieszak
Copy link

+1

@Awk34 Awk34 added the Heroku label Dec 2, 2015
@dimkk
Copy link

dimkk commented Dec 8, 2015

+1
This is not heroku specific, azure - same

@arkdelkaos
Copy link

Is not a server-related error: grunt-filerev is renaming the files, but then (usemin?) the changes are not being fixed on the css files.
In fact, not only that: for example, in my case, I'm using function to get the name of the image, so this changes are not easy for me. Maybe I could find the hash 'somehow', but I don't have time to work it out right now :(

Until is fixed, you can comment 'filerev' in the grunt task 'build' at the Gruntfile.js, and then the filenames will not be renamed :)
The rename thing. as you may read at https://github.com/yeoman/grunt-filerev, is for browser caching purposes; IMHO you can live without it for a while 👍

@Awk34
Copy link
Member

Awk34 commented Mar 10, 2016

Does anyone have reproduction instructions?

@Awk34 Awk34 removed the major label Mar 10, 2016
@Awk34
Copy link
Member

Awk34 commented May 18, 2016

Closed due to inactivity

@Awk34 Awk34 closed this as completed May 18, 2016
@bestconsultant
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants