vinyl-sourcemaps-apply

0.2.1 • Public • Published

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);
};

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.1
    1,398,026
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.2.1
    1,398,026
  • 0.2.0
    150
  • 0.1.4
    65,291
  • 0.1.3
    34
  • 0.1.2
    2
  • 0.1.1
    3
  • 0.1.0
    3

Package Sidebar

Install

npm i vinyl-sourcemaps-apply

Weekly Downloads

883,005

Version

0.2.1

License

ISC

Last publish

Collaborators

  • floridoo