diff --git a/src/index.js b/src/index.js index 6717d36c..3cd0df76 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 && 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)));