biobulkbende.org/node_modules/vinyl-sourcemaps-apply
Tancre 0efda7fffe structure, layout and automation 2020-09-16 14:23:28 +02:00
..
.jshintrc structure, layout and automation 2020-09-16 14:23:28 +02:00
.npmignore structure, layout and automation 2020-09-16 14:23:28 +02:00
README.md structure, layout and automation 2020-09-16 14:23:28 +02:00
index.js structure, layout and automation 2020-09-16 14:23:28 +02:00
package.json structure, layout and automation 2020-09-16 14:23:28 +02:00

README.md

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