1 # vinyl-sourcemaps-apply
3 Apply a source map to a vinyl file, merging it with preexisting source maps.
8 var applySourceMap = require('vinyl-sourcemaps-apply');
9 applySourceMap(vinylFile, sourceMap);
12 ### Example (Gulp plugin):
15 var through = require('through2');
16 var applySourceMap = require('vinyl-sourcemaps-apply');
17 var myTransform = require('myTransform');
19 module.exports = function(options) {
21 function transform(file, encoding, callback) {
22 // generate source maps if plugin source-map present
24 options.makeSourceMaps = true;
27 // do normal plugin logic
28 var result = myTransform(file.contents, options);
29 file.contents = new Buffer(result.code);
31 // apply source map to the chain
33 applySourceMap(file, result.map);
40 return through.obj(transform);