Build -prod Mangles CSS #9255
Labels
area: @angular-devkit/build-angular
devkit/build-angular:browser
freq2: medium
needs: investigation
Requires some digging to determine if action is needed
severity3: broken
type: bug/fix
Milestone
Running
ng build -prod
runs minification on CSS, which removes units from rules with values such as0px
or0%
. This is not always desirable behavior, as browsers will handle these unit-less values differently, in some cases breaking the intended layout of the page.Versions
Repro steps
div
with class offoo
to a component.width: 0%;
to thefoo
class.ng serve
.width: 0%
as it was defined in code.ng serve --prod
.width: 0
.Observed behavior
The styles output from the production build do not include units on CSS rules with values of 0.
Desired behavior
The styles output from the production build should include the specified unit on CSS rules with values of 0. Ideally, this should be configurable as not everyone will want this as default behavior.
Justification
I understand that in an ideal world we would prefer to use standard, well-formed CSS to style our applications. However, in practice we often run into situations where we have to work around various browser implementations to provide cross browser support. Sometimes this means implementing some very specific CSS hacks.
In most cases it is desirable to drop the units from 0 value rules for a more compressed file, but sometimes we need to force the browser into reading these values as certain units, specifically when using flex rules.
https://stackoverflow.com/questions/47040371/why-flex-container-flex-1-0-0px-collapses-on-chrome
https://github.com/philipwalton/flexbugs#flexbug-4
The text was updated successfully, but these errors were encountered: