gulp-bower-overrides

0.1.1 • Public • Published

gulp-bower-overrides Build Status

Merge overrides into bower.json files to produce "fixed" packages.

Install

$ npm install --save-dev gulp-bower-overrides

Usage

Define an overrides block in your bower.json per the proposed spec: an inline object literal or path to .json file that defines a map of package names to overridden properties.

Take the Lodash package as an example. By default, Lodash's bower.json specifies lodash.compat.js as the main file, which is the compatibility build for new & old environments. If you'd like to use the fancy modern build instead, you could provide the following overrides definition in your application's root bower.json file:

{
  "name": "my-application",
  "dependencies": {
    "lodash": "latest"
  },
  "overrides": {
    "lodash": {
      "main": "./dist/lodash.js"
    }
  }
}

Then define a gulp task that runs each bower.json file through the plugin. The contents of each bower.json will be merged with the corresponding overrides block (if present) to produce a new bower.json according to your wishes.

var gulp = require('gulp');
 
gulp.task('bower', function () {
  var bowerOverrides = require('gulp-bower-overrides');
 
  return gulp.src('bower_components/*/bower.json')
    .pipe(bowerOverrides())
    .pipe(gulp.dest('dist'));
});

Example output Lodash bower.json (trimmed for readability) given configuration above:

{
  "name": "lodash",
  "version": "2.4.1",
  "main": "./dist/lodash.js"
}

API

bowerOverrides(options)

The plugin itself. Merges overrides with each bower.json.

options

bowerPath

Type: String
Default: './bower.json'

Path to project bower.json file with overrides block. Defaults to bower.json in root project directory.

bowerComponentsPath

Type: String
Default: './bower_components/'

Path to bower package install directory. Defaults to bower_components/ in root project directory. Used to expand globs if expandGlobs option is enabled.

overrides

Type: String, Object

Path to a .json file or object literal value containing package overrides. If provided, this value will be used instead of loading from a bower.json file.

expandGlobs

Type: Boolean
Default: false

Expand globs in main block to all matched files using node-glob. This is useful because the bower.json spec does not support globs in main by default, but some plugins do.

NOTE: If you're using a custom install directory, be sure to set the bowerComponentsPath option above to that path.

bowerOverrides.mapJSON(iterator)

A thin wrapper around through2-map.obj() that passes the parsed JSON content of each file to the iterator and updates the content with stringified return value.

iterator

Map function to call for each file in stream. Receives (json, file) arguments and returns new JSON content.

License

MIT © Palantir Technologies

Package Sidebar

Install

npm i gulp-bower-overrides

Weekly Downloads

28

Version

0.1.1

License

MIT

Last publish

Collaborators

  • giladgray