MCPcopy Index your code
hub / github.com/webpack/css-loader / normalizeSourceMapForRuntime

Function normalizeSourceMapForRuntime

src/utils.js:926–968  ·  view source on GitHub ↗
(map, loaderContext)

Source from the content-addressed store, hash-verified

924}
925
926function normalizeSourceMapForRuntime(map, loaderContext) {
927 const resultMap = map ? map.toJSON() : null;
928
929 if (resultMap) {
930 delete resultMap.file;
931
932 /* eslint-disable no-underscore-dangle */
933 if (
934 loaderContext._compilation &&
935 loaderContext._compilation.options &&
936 loaderContext._compilation.options.devtool &&
937 loaderContext._compilation.options.devtool.includes("nosources")
938 ) {
939 /* eslint-enable no-underscore-dangle */
940
941 delete resultMap.sourcesContent;
942 }
943
944 resultMap.sourceRoot = "";
945 resultMap.sources = resultMap.sources.map((source) => {
946 // Non-standard syntax from `postcss`
947 if (source.indexOf("<") === 0) {
948 return source;
949 }
950
951 const sourceType = getURLType(source);
952
953 if (sourceType !== "path-relative") {
954 return source;
955 }
956
957 const resourceDirname = path.dirname(loaderContext.resourcePath);
958 const absoluteSource = path.resolve(resourceDirname, source);
959 const contextifyPath = normalizePath(
960 path.relative(loaderContext.rootContext, absoluteSource),
961 );
962
963 return `webpack://./${contextifyPath}`;
964 });
965 }
966
967 return JSON.stringify(resultMap);
968}
969
970function printParams(media, dedupe, supports, layer) {
971 let result = "";

Callers 1

getModuleCodeFunction · 0.85

Calls 2

getURLTypeFunction · 0.85
normalizePathFunction · 0.85

Tested by

no test coverage detected