Open htho opened 5 years ago
PR welcome to fix this.
Puh.
I wouldn't even know where to start. I have no clue about the interaction between postcss and postcss-import.
If I add a dummy comment, the file is in the sourcemap.
That is the only way to "fix" this.
postcss-import
removes @import
statements and anything that is imported will be coming from other files.
If a file contains only @import
statements it will never be part of the source maps.
We could automatically add a comment with the @import
statement as comment text :
/* @import "foo.css" */
But any half decent minifier will scrub comments, re-introducing the issue.
I am also unsure what the use case is. Technically the file is missing from the source maps, but is this a problem? Sourcemaps should still work for all other CSS.
If so, which problem? Are there alternative solutions?
We could automatically add a comment with the @import statement as comment text :
/* @import "foo.css" */
esbuild
seems to do something like this.
style.css
:
@import url("a.css");
a.css
:
.box {
background-color: green;
}
becomes :
/* tests/001-core-features/001/default/a.css */
.box {
background-color: green;
}
/* tests/001-core-features/001/default/style.css */
If someone wants this badly enough they're willing to submit a PR, we can consider it. But I don't see the point of adding it just for the sake of it. So far, one request in ~4 years; doesn't seem to be a common need.
Yeah, I also fail to see the issue.
I don't think the fact that it's missing from a sourcemap is breaking anything or can cause any inconvenience.
I have file that has only @import rules, but nothing else. This file can not be found in the sourcemap. If I add a dummy comment, the file is in the sourcemap.
Maybe this is related to: #81?
I created a minimally working example: https://github.com/htho/mwe-postcss-import-sourcemap-import-only