Elasticsearch-js: Separate angular js version of elasticsearch in bower package

Created on 25 Nov 2014  路  6Comments  路  Source: elastic/elasticsearch-js

I'm using Yeoman and there is Grunt which automatically insert dependencies to index.html. And instead of choosing elasticsearch.angular.js its select elasticsearch.js and I can't do anything about it.
And I can't change it by hand because of synchronizations with bower.json
Thanks!

Most helpful comment

There is an easy trick: adding next block to bower.json

"overrides": {
  "elasticsearch": {
    "main": "elasticsearch.angular.js"
  }
}

so Grunt tasks like wiredep choose the angular version instead of the "main" one

All 6 comments

Most of those plugins allow you to specify alternate "main" files I believe. Yet still I also think this is a good idea. Not sure when I'll have spare time to implement it though.

+1

Just a thought. If you are already using Grunt, then maybe grunt-wiredep or grunt-bower-install will help. Wouldn't adding something on the lines of below for the wiredep task help?

fileTypes: {
      html: {
        replace: {
          js: function(filePath) {
            var baseURLEndPos = filePath.lastIndexOf('/');
            var extPos = filePath.indexOf('.');
            var libName = filePath.substring(baseURLEndPos + 1, extPos);
            if (libName === 'elasticsearch') {
              var newFile = filePath.substring(0, extPos) + '.angular.' + filePath.substring(extPos + 1);
              return '<script src="' + newFile + '"></script>';
            }
            return '<script src="' + filePath + '"></script>';
          }
        }
      }
    }

There is an easy trick: adding next block to bower.json

"overrides": {
  "elasticsearch": {
    "main": "elasticsearch.angular.js"
  }
}

so Grunt tasks like wiredep choose the angular version instead of the "main" one

thanks @jmfernandez ~ :+1: it solved my problem

I think the concept by using unofficial overrides property in bower.json is the best solution in this case.
(wiredep doc: https://github.com/taptapship/wiredep/blob/db78c86b4226971537e1fc61a32edc75557406f8/readme.md#bower-overrides)

@spalger maybe this issue can be closed :smile:

Hi! I'm closing this due to inactivity, if it is still an issue, please feel free to reopen! :)

Was this page helpful?
0 / 5 - 0 ratings