Created by: buildbreakdo
Fixes #6282 (closed): If build compiler error has postcssNode property, add additional information to the error message. Default compiler CSS error messages are opaque. To verify:
npx create-react-app css-test
cd css-test
echo "label[for=*] { margin-right: 12px; }" > ./src/App.css
yarn build
Replace css-test/node_modules/react-scripts/build.js lines:
messages = formatWebpackMessages({
errors: [err.message],
warnings: [],
});
With :
let errMessage = err.message;
// Add additional information for postcss errors
if (err.hasOwnProperty('postcssNode')) {
errMessage += '\n' + path.basename(
err['postcssNode'].source.input.file
) + '\nCompileError: Begins at selector ' +
err['postcssNode'].selector +' (' +
err['postcssNode'].source.start.line + ':' +
err['postcssNode'].source.start.column +
')';
}
messages = formatWebpackMessages({
errors: [errMessage],
warnings: [],
});