Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

usemin can add filerev only if uglify is disable and only on one particular url #579

Open
casertap opened this issue Aug 4, 2015 · 0 comments

Comments

@casertap
Copy link

casertap commented Aug 4, 2015

I have an issue with usemin.
I decided to add a simple filter to my angular app so I can check if the url I get back from the the server starts with "/assets/site/default-cover". If this is the case then I need to change this link to point to the revised image:

angular.module('coverUrlFilter', []).filter('coverurlfilter', ->
  return (input) ->
    if input.indexOf("/assets/site/default-cover") == 0
      return "/assets/site/default-cover.jpg"
    else
      return input
)

my usemin task is pretty simple and works for every others urls on my js file

usemin: {
      html: ['<%= yeoman.dist %>/<%= yeoman.outputHtmlName %>'],
      css: ['<%= yeoman.dist %>/*.css'],
      js: '<%= yeoman.dist %>/*.js',
      json: '<%= yeoman.dist %>/assets/*.json',
      //To add a digest code on html files
      //ngInclude: ['<%= yeoman.dist %>/*.html' , '<%= yeoman.dist %>/views/{,*/}*{,*/}*.html'],
      options: {
        assetsDirs: ['<%= yeoman.dist %>','<%= yeoman.dist %>/assets'],
        patterns: {
          //cd assets
          //find . -type f -name '*.*' | sed 's|.*\.||' | sort -u
          js: [
            [/(assets\/.*?\.(?:PNG|db|eot|gif|ico|jpg|json|mp4|otf|png|svg|ttf|webm|woff))/gm, 'Update the JS to reference our revved images']
          ],
          css: [
            [/(assets\/.*?\.(?:PNG|db|eot|gif|ico|jpg|json|mp4|otf|png|svg|ttf|webm|woff))/gm, 'Update the CSS to reference our revved images']
          ],
          json: [
            [/(assets\/.*?\.(?:PNG|db|eot|gif|ico|jpg|json|mp4|otf|png|svg|ttf|webm|woff))/gm, 'Update the JSON to reference our revved images']
          ]

        }
      }
    },

I could print the filerev summery object between the filerev task and the usemin task and I could find this data:

"dist/assets/site/default-cover.jpg":"dist/assets/site/default-cover.79f3f28a.jpg"

This is identical to every others url that work perfectly

my useminPrepare

 useminPrepare: {
      html: '<%= yeoman.dist %>/<%= yeoman.outputHtmlName %>',
      options: {
        dest: '<%= yeoman.dist %>/',
        flow: {
          html: {
            steps: {
              js: [  'concat', 'uglifyjs'],
              css: [ 'concat', 'cssmin']
            },
            post: {
            }
          }
        }
      }
    },

If I run the code I get

return function(input){return 0===input.indexOf("/assets/site/default-cover")?"/assets/site/default-cover.jpg":input}})}.call(this)

So revision is not added on this particular url but if correctly added on others.

What is more surprising is that if I remove the uglify task and I just copy the file to the right place.
usemin do a good job by adding the revision number.

 copy: {
      insteadofuglify: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.tmp %>/concat',
          src: ['*.js'],
          dest: '<%= yeoman.dist %>/'
        }]
      },
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant