vinyl-sourcemaps-apply / 0.2.1 last updated 3 months ago created on May 11th 2014

Install

npm install --save vinyl-sourcemaps-apply

Clone

git clone git@github.com:floridoo/vinyl-sourcemaps-apply.git

dependencies

main source-map 0.5.3 BSD 3-Clause

maintainers

floridoo

versions 7 total

0.2.1 3 months ago floridoo
0.2.0 6 months ago floridoo
0.1.4 2 years ago floridoo
0.1.3 2 years ago floridoo
0.1.2 2 years ago floridoo
0.1.1 2 years ago floridoo
0.1.0 2 years ago floridoo
78355 Downloads yesterday.

readme

vinyl-sourcemaps-apply

Apply a source map to a vinyl file, merging it with preexisting source maps.

Usage:

var applySourceMap = require('vinyl-sourcemaps-apply');
applySourceMap(vinylFile, sourceMap);

Example (Gulp plugin):

var through = require('through2');
var applySourceMap = require('vinyl-sourcemaps-apply');
var myTransform = require('myTransform');

module.exports = function(options) {

  function transform(file, encoding, callback) {
    // generate source maps if plugin source-map present
    if (file.sourceMap) {
      options.makeSourceMaps = true;
    }

    // do normal plugin logic
    var result = myTransform(file.contents, options);
    file.contents = new Buffer(result.code);

    // apply source map to the chain
    if (file.sourceMap) {
      applySourceMap(file, result.map);
    }

    this.push(file);
    callback();
  }

  return through.obj(transform);
};
Resolving all dependencies.. This could take a while as our cache is not yet fully warmed up.