Luismahou / grunt-hashres

Hashes your js and css files and rename the <script> and <link> declarations that refer to them in your html/php/etc files.
MIT License
115 stars 41 forks source link

inserting filenames with old hashes #31

Open bprodoehl opened 10 years ago

bprodoehl commented 10 years ago

I love this project, but I'm seeing it stumble on some images and stick with old filenames that don't exist anymore. Here's my task:

hashres: {
      options: {
        encoding: 'utf8',
        fileNameFormat: '${name}.${hash}.cache.${ext}',
        renameFiles: true
      },
      css: {
        options: {
        },
        src: [
          'dist/css/*.css' ],
        dest: 'dist/*.html'
      },
      js: {
        options: {
        },
        src: [
          'dist/js/*.js'
        ],
        dest: 'dist/*.html'
      },
      images: {
        options: {
        },
        src: [
          'dist/images/*.png',
          'dist/images/*.jpg'
        ],
        dest: [
          'dist/*.html',
          'dist/css/*.css',
          'dist/js/*.js',
          'dist/templates/*.ejs'
        ]
      },
      templates: {
        options: {
        },
        src: [
          'dist/templates/*.ejs'
        ],
        dest: [
          'dist/js/*.js'
        ]
      }
    }

Because of a bug in imagemin, all my images get new hashes on each clean rebuild, and what I'm seeing is for at least one file, it's replacing the image's filename in a .js file with an old hash, and that image file with that old hash doesn't exist anymore. This is with 0.4.0, and I'm going to try going back to 0.3.4. I'm also going to try disabling some of my other tasks, to see if it may be a conflict with concat, uglify, or something else, but it gets most of the files right.

This is starting from a clean build, with no dist folder whatsoever, and the filename with the old hash doesn't exist anywhere in my source tree.

bprodoehl commented 10 years ago

0.3.4 with the same task seems to work great.

Luismahou commented 10 years ago

In version 0.4.0 there's a new feature that allows to run hashres task to update hashed references on destination files that were already modified in a previous build. I wouldn't be surprise if a bug slipped in with that new feature.

I plan to work on the plugin this week, so I'll have a look. In the meantime use 0.3.4.

Could you please put an extract of a destination file badly updated and tell me what were you expecting.

Thanks