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
ParserError when dividing a CSS variable by a negative number #10880
Comments
Problem and ErrorI can confirm this. The following rules will cause an error during
The error is:
BTW the rule is not in line 1 column 25, so it is totally misleading. Solutions
This code is from Bootstrap 5.0.2 which has the spaces (even in the minified version) so my assumption is that somewhere, the script minifies it again and removes the spaces. This could explain why it works in dev mode, where presumably there is no minification. Also, check out this related Stack Overflow question. |
Thanks for the solutions @totymedli but where can you change those ? |
I'm having something similar. This does not work. But this works. Also using Bootstrap. |
Found the fix : Change :
with
|
@fewlme You are editing a 3rd party library. That works only if you add the dependency directly to your project. If it is inside |
True @totymedli, it's more a hack until I npm update the hell out of it :) but I can now build my react app without the parserError |
Sass recently added additional features for
It seems like some other tool is parsing Sass's output and choking on this valid CSS, which is likely a bug in that tool. |
Just adding another workaround: moving the literal values to the front of the expression seems to avoid any problems caused by minification or other processing, e.g.
Merely adding whitespace in front of the minus sign in the literals was not sufficient for me. For reference, I am using react-scripts 4.0.3, sass 1.45.2, and CSS modules. I found the idea for this workaround from: https://issueexplorer.com/issue/react-bootstrap/react-bootstrap/6039 |
This can be resolved if using bootstrap 5.1.0 with the following patch put this in {
"scripts":{
"postinstall":"patch-package"
},
"devDependencies":{
"patch-package":"^6.4.7"
}
} |
Describe the bug
Dividing a CSS variable by a negative number yields a
ParserError
during production builds. Live preview works ok.Which terms did you search for in User Guide?
ParserError, CSS variables
Environment
Steps to reproduce
npx create-react-app --template typescript
App.css
:npm run build
Expected behavior
The build should compile successfully, since live preview works as expected.
Actual behavior
Etc
If either
var(--size)
is replaced by some constant, or the expression is rewritten ascalc(-1/2 * var(--size))
, the problem disappears.The text was updated successfully, but these errors were encountered: