vinyl-sourcemaps-apply
Apply a source map to a vinyl file, merging it with preexisting source maps
Last updated 5 years ago by floridoo .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install vinyl-sourcemaps-apply 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.2.1                                ...           latest (5 years ago)

7 Versions

  • 0.2.1                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.4                                ...           6 years ago
  • 0.1.3                                ...           6 years ago
  • 0.1.2                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 752
This Week 9,414
This Month 16,937
Last Day 2,135
Last Week 11,656
Last Month 47,308
Dependencies (1)
Dev Dependencies (0)
None
Dependents (309)

Copyright 2014 - 2016 © taobao.org |