Skip to content

Commit c2d5321

Browse files
fix: source map generation for cleancss
1 parent 7ae4946 commit c2d5321

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/utils.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,21 @@ async function cleanCssMinify(input, inputSourceMap, minimizerOptions) {
161161
...minimizerOptions,
162162
}).minify({ [name]: { styles: code } });
163163

164+
const sourceMap = result.sourceMap && result.sourceMap.toJSON();
165+
166+
// workaround for source maps on windows
167+
if (sourceMap) {
168+
// eslint-disable-next-line global-require
169+
const isWindowsPathSep = require("path").sep === "\\";
170+
171+
sourceMap.sources = sourceMap.sources.map((item) =>
172+
isWindowsPathSep ? item.replace(/\\/g, "/") : item
173+
);
174+
}
175+
164176
return {
165177
code: result.styles,
166-
map: result.sourceMap && result.sourceMap.toJSON(),
178+
map: sourceMap,
167179
warnings: result.warnings,
168180
};
169181
}

0 commit comments

Comments
 (0)