From 583573da4f8cc3779f50190c2a5b12fc9586ef1e Mon Sep 17 00:00:00 2001 From: alexhisen Date: Wed, 18 Mar 2020 00:58:51 -0700 Subject: [PATCH 1/2] fix: work-around for apparent bug in postcss that loses the paths to source files in existing map previously generated by postcss-loader --- src/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/index.js b/src/index.js index 6717d36c..748ed8fe 100644 --- a/src/index.js +++ b/src/index.js @@ -2,6 +2,8 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ +import path from 'path'; + import { getOptions, isUrlRequest } from 'loader-utils'; import postcss from 'postcss'; import postcssPkg from 'postcss/package.json'; @@ -87,6 +89,15 @@ export default function loader(content, map, meta) { : false, }) .then((result) => { + // work-around for apparent bug in postcss that loses the paths to source + // files in existing map previously generated by postcss-loader: + if (result.map && map.file) { + /* eslint-disable no-underscore-dangle, no-param-reassign */ + result.map._sourceRoot = path.dirname(map.file); + result.map._file = map.file; + /* eslint-enable */ + } + result .warnings() .forEach((warning) => this.emitWarning(new Warning(warning))); From 1d389f178a6339c67fa4f16fe831ca38cbd97fc8 Mon Sep 17 00:00:00 2001 From: alexhisen Date: Wed, 18 Mar 2020 01:33:04 -0700 Subject: [PATCH 2/2] fix: work-around for apparent bug in postcss that loses the paths to source files in existing map previously generated by postcss-loader --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 748ed8fe..3cd0df76 100644 --- a/src/index.js +++ b/src/index.js @@ -91,7 +91,7 @@ export default function loader(content, map, meta) { .then((result) => { // work-around for apparent bug in postcss that loses the paths to source // files in existing map previously generated by postcss-loader: - if (result.map && map.file) { + if (result.map && map && map.file) { /* eslint-disable no-underscore-dangle, no-param-reassign */ result.map._sourceRoot = path.dirname(map.file); result.map._file = map.file;