wecui
Version:
一款基于Vue2.x版本的移动端web组件
42 lines (31 loc) • 939 B
Markdown
file, merging it with preexisting source maps.
```javascript
var applySourceMap = require('vinyl-sourcemaps-apply');
applySourceMap(vinylFile, sourceMap);
```
```javascript
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);
};
```
Apply a source map to a vinyl