Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally sourceRoot should be empty and each sources relative to webpack context with unique prefix, we will improve source maps for css pipeline in near future, so please open issue with reproducible test repo and we will find solution

result.map._file = map.file;
/* eslint-enable */
}

result
.warnings()
.forEach((warning) => this.emitWarning(new Warning(warning)));
Expand Down