JavaScript how to replace links to versioned files of ui-router with usemin

Given the following file app.js

$stateProvider
      .state('intro', {
        url: '/intro',
        templateUrl: 'partials/intro.html',
        controller: 'IntroController as IntroCtrl'
      })
      .state('search', {
        url: '/search',
        templateUrl: 'partials/search.html',
        controller: 'SearchController as searchCtrl'
      })
      ;

The task is to change the templateUrl files to their revisioned counterparts which were revisioned with grunt filerev.

I have a usemin target with grunt

useminPrepare: {// configuration which tasks usemin will change/run
       html: build_src + '/index.html',             
       options: {
            dest: build_dest + '',
        }
},      
usemin: {           
     html: [build_dest + '/index.html'],            
     options: {
            dirs: [build_dest + '', build_dest + '/dist']           
     }      
}

It is documented how to insert block comments in html and then usemin performs the revisioning and also the replacement of revisioned files.

How it is achieved for the javascript file?

Answer:1

I continued to search after the answer of cetia

I found the solution at: https://github.com/yeoman/grunt-usemin/issues/235#issuecomment-33316221

usemin: {
            html: [build_dest + '/index.html'],
            js:[build_dest + '/**/*.js'],
            options: {
                dirs:[build_dest, build_dest + '/dist'],
                assetsDirs: [build_dest],
                patterns: {
                      // FIXME While usemin won't have full support for revved files we have to put all references manually here
                      js: [
                          [/(partials\/.*?\.html)/gm, 'Update the JS to reference our revved partials']
                      ]
                }
            }
        }

The important additions are the patterns. You need to say to usemin how to search the html links in javascript.

The assetDirs option is also important to set because usemins fileprocessor.js looks for the revved files by a map of unrevved to revved files and if the assetDirs is not set properly it won't find it.

Answer:2

My javascript foo is okay but I haven't kept up with the latest and greatest (we don't use Node.js in backend). What is the modern practice of structuring client side javascript? We organize ...

My javascript foo is okay but I haven't kept up with the latest and greatest (we don't use Node.js in backend). What is the modern practice of structuring client side javascript? We organize ...

This is my collection: { "_id" : 10926400, "votes": 131, "author": "Jesse", "comments" : [ { "id" : 1, ...

This is my collection: { "_id" : 10926400, "votes": 131, "author": "Jesse", "comments" : [ { "id" : 1, ...

I've just figured out that object in React's state that have multiple children cannot be rendered easily. In my example I have component which speaks with third-party API through AJAX: var Component ...

I've just figured out that object in React's state that have multiple children cannot be rendered easily. In my example I have component which speaks with third-party API through AJAX: var Component ...

  1. react deep object comparison
  2. react deep object compare
  3. react object deep copy
  4. react object deep merge
  5. react setstate deep object
  6. react deep clone object
  7. react state deep object
  8. react deep clone state object
  9. react js deep copy object

I'm working on an app that starts a Google Hangout On Air. We do this programmatically using Javascript and the Google+ Hangouts API. We've successfully created the button and when you click it, it ...

I'm working on an app that starts a Google Hangout On Air. We do this programmatically using Javascript and the Google+ Hangouts API. We've successfully created the button and when you click it, it ...

  1. google hangouts does not ring
  2. google hangouts does not work
  3. google hangouts how does it work
  4. google hangouts what does active mean
  5. google hangouts camera doesn't work
  6. what does google hangouts do
  7. does google hangouts cost money
  8. does google hangouts still work
  9. does google hangouts use data
  10. does google hangouts notify screenshots
  11. does google hangouts work internationally
  12. does google hangouts have screen sharing
  13. does google hangouts work in uae
  14. does google hangouts charge for calls
  15. does google hangouts work in dubai
  16. does google hangouts record calls
  17. does google hangouts work in china
  18. does google hangouts show your location
  19. does google hangouts have video chat
  20. does google hangouts use wifi