autoprefixer
autoprefixer copied to clipboard
Warnings show incorrect file info (css string with map file)
My issue is specifically related to the grid: "autoplace" option. But I'd imagine it applies anywhere a warning is raised.
Actual warning snippet:
- Line: 1
- Column: 10
- File:
c:\Path\Sample\_AutoprefixExample\File-With-Import.scss(fromnode.source.input.file)
Expected warning snippet:
- Line: 2
- Column: 4
- File:
c:\Path\Sample\_AutoprefixExample\_import-me.scss
Code
const
prefixer = postcss(
autoprefixer({
overrideBrowserslist: [
'> 0.5%'
'last 2 versions'
'Firefox ESR'
'not dead'
],
grid: "autoplace",
})
),
result =
await prefixer.process(
"div.Test{grid-template-columns:1fr 3fr}",
{
from: 'c:\\Path\\Sample\\_AutoprefixExample\\File-With-Import.scss',
to: 'c:\\Path\\Sample\\Assets\\Style\\File-With-Import.css',
map: {
inline: false,
prev: map, // <-- See map below
},
}
);
result.warnings().forEach((warn) => {
const
file = warn.node.source.input.file,
line = warn.line,
column = warn.column;
});
MAP
{
"version":3,
"sourceRoot":"",
"sources":["../../_AutoprefixExample/_import-me.scss"],
"names":[],
"mappings":"AAAA,SACI",
"file":"file:///c:/Path/Sample/_AutoprefixExample/File-With-Import.css"
}
File-With-Import.scss
@import 'import-me'
_import-me.scss
div.Test {
grid-template-columns: 1fr 3fr;
}
Good idea. Do you want to send PR?
I'm happy to take a look when I can. Where's a good place to start? Rather than trundling through all the files, can I ask: where are the warnings raised and maps parsed?
- Find all
.warn(calls in Autoprefixer sources. - Check
Node#warn()in PostCSS. It should use the node origin. Debug why it is not happening.