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

Using more complex calculations in CSS calc expressions will be incorrect in production builds #17890

Closed
loxy opened this issue Jun 9, 2020 · 1 comment · Fixed by #17891
Closed

Comments

@loxy
Copy link

loxy commented Jun 9, 2020

🐞 bug report

Affected Package

"@angular-devkit/build-angular": "~0.901.7",
"@angular/cli": "~9.1.7",
"@angular/compiler-cli": "~9.1.9",

Is this a regression?

I don't think so...

Description

When using more complex calculations in CSS calc expressions, production builds will be incorrect. Have look at the sample repo:

I have added the following to styles.css:

:root {
    --width-a: 10em;
}
.box {
    background-color: #ccc;
    width: calc(var(--width-a)/2 + var(--width-a)/2);
    height: calc(var(--width-a)/2 + var(--width-a)/2);
}

which gets compiled to the following in production builds (ng build --prod):

.box {
    background-color: #ccc;
    width: calc(var(--width-a) + var(--width-a));
    height: calc(var(--width-a) + var(--width-a));
}

I think the problem comes from: postcss/postcss-calc#107. But not sure if this plugin is used under the hood.
Unfortunately we cannot disable specific PostCSS plugins: #8427

🔬 Minimal Reproduction

See: https://github.com/loxy/angular-cs-calc-bug

🌍 Your Environment

Angular Version:


Angular CLI: 9.1.7
Node: 12.12.0
OS: win32 x64

Angular: 9.1.9
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.901.7
@angular-devkit/build-angular     0.901.7
@angular-devkit/build-optimizer   0.901.7
@angular-devkit/build-webpack     0.901.7
@angular-devkit/core              9.1.7
@angular-devkit/schematics        9.1.7
@angular/cli                      9.1.7
@ngtools/webpack                  9.1.7
@schematics/angular               9.1.7
@schematics/update                0.901.7
rxjs                              6.5.5
typescript                        3.8.3
webpack                           4.42.0

Anything else relevant?
No

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants