Skip to content

Commit

Permalink
fix: source map generation for cleancss
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Nov 10, 2021
1 parent 7ae4946 commit c2d5321
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,21 @@ async function cleanCssMinify(input, inputSourceMap, minimizerOptions) {
...minimizerOptions,
}).minify({ [name]: { styles: code } });

const sourceMap = result.sourceMap && result.sourceMap.toJSON();

// workaround for source maps on windows
if (sourceMap) {
// eslint-disable-next-line global-require
const isWindowsPathSep = require("path").sep === "\\";

sourceMap.sources = sourceMap.sources.map((item) =>
isWindowsPathSep ? item.replace(/\\/g, "/") : item
);
}

return {
code: result.styles,
map: result.sourceMap && result.sourceMap.toJSON(),
map: sourceMap,
warnings: result.warnings,
};
}
Expand Down

0 comments on commit c2d5321

Please sign in to comment.