Search code examples
buildgruntjsuriboweryo

Adding the uri.js bower component breaks my Grunfile.js, which dies thinking the uri.js directory is a file. How to fix?


The Yeoman generated Gruntfile.js dies during a grunt build with:

Running "rev:dist" (rev) task
dist/public/app/app.js >> b90d2f58.app.js
dist/public/app/vendor.js >> 2deb5480.vendor.js
Warning: Unable to read "dist/public/bower_components/uri.js" file (Error code: EISDIR). Used --force, continuing.

Clearly it is interpreting the uri.js component directory as a file! One simple fix is to rename the uri.js component to uri_js or something similar. But rather than do that, is there an easy switch to add to the utility that does the Hashing to know that 'uri.js' is not a file??? I already tried adding "filter: 'isFile'" to every place in the Gruntfile that has *.js as a pattern, to no avail.

Anyone who has already seen this, your help is appreciated. For now I am simply doing grunt build --force. Thanks


Solution

  • I finally discovered that one can exclude this bower_component from the rename process. The key is that order of the files in the rev piece is dependent on the order of selection. So I modified this section of my Gruntfile.js ... and all is well.

    // 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/*',
            '!<%= yeoman.dist %>/public/bower_components/uri.js'
          ]
        }
      }
    

    The crucial addition was this last piece:

            '!<%= yeoman.dist %>/public/bower_components/uri.js'
    

    I hope this helps someone else with with this issue!