-
Notifications
You must be signed in to change notification settings - Fork 121
Open
Description
It would be great if rework could write a source map not only to a comment, but optionally to a file. It could look something like this (just pseudo code):
// rework/index.js
Rework.prototype.toString = function(options){
options = options || {};
var result = stringify(this.obj, options);
if (options.sourcemap && !options.sourcemapAsObject) {
if(!options.sourcemapAsFile) {
result = result.code + '\n' + sourcemapToComment(result.map);
} else {
// options.sourcemapAsFile could be a boolean so filePath will be dest file appended with ".map" or it could be a string with custom path
var filePath = get file path from options.sourcemapAsFile;
result = result.code + '\n' + sourcemapToFile(result.map, filePath);
}
}
return result;
};
function sourcemapToFile(map, filePath) {
var convertSourceMap = require('convert-source-map');
fs.writeFilSync(filePath, convertSourceMap.fromObject(map));
return '/*# sourceMappingURL=' + filePath + ' */';
}
Metadata
Metadata
Assignees
Labels
No labels