Skip to content

Commit

Permalink
perf(sourcemap): less operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Anidetrix committed Mar 15, 2020
1 parent d3405aa commit 178e2d4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,19 @@ export default (options: Options = {}): Plugin => {
}

let code = concat.content.toString();
const map = concat.sourceMap;
const map = concat.sourceMap && new MapModifier(concat.sourceMap);

if (map) {
if (options.sourceMap === "inline") {
code += new MapModifier(map).toCommentData();
code += map.toCommentData();
} else if (options.sourceMap === true) {
code += new MapModifier(map).toCommentFile(fileName);
code += map.toCommentFile(fileName);
}
}

return {
code,
map: options.sourceMap === true ? map : undefined,
map: options.sourceMap === true && map ? map.toString() : undefined,
codeFileName: fileName,
mapFileName: `${fileName}.map`,
};
Expand Down

0 comments on commit 178e2d4

Please sign in to comment.