Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

work-around for lost paths to source files in source map #1053

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/index.js
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