Prod build re-orders and alters scss styles
See original GitHub issueVersions
Angular CLI: 1.7.4 (e)
Node: 8.11.1
OS: win32 x64
Angular: 5.2.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.7.4
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack-dev-server: 2.11.2
webpack: 3.11.0
Repro steps
- Step 1 ng new test-proj-name --minimal true --style scss
- Step 2 Paste following into styles.scss
$border-size: 1px;
$size: 0.125rem;
$color: #cccccc;
@mixin border-standard {
border-width: $border-size;
border-style: solid;
border-radius: $size;
border-color: $color;
}
th {
@include border-standard;
border-radius: 0;
border-top: 0;
border-right: 0;
border-left: 0;
}
- Step 3 ng build -ec
- Step 4 View the following css output in dist/styles.bundle.css:
th {
border-width: 1px;
border-style: solid;
border-radius: 0.125rem;
border-color: #cccccc;
border-radius: 0;
border-top: 0;
border-right: 0;
border-left: 0; }
- Step 5 ng build -prod
- Step 6 View the following css output in dist/styles.GUID.bundle.css:
th{border-radius:0;border-top:0;border-right:0;border-left:0;border:1px solid #ccc}
Observed behavior
The border-width, border-style, and border-color have been combined into the single border shorthand property and moved to the end of the th selector when using the -prod flag. This negates the fact that border-left, border-right, and border-top properties were all set to 0 in the original scss to override the border. It is now these settings that are being overwritten.
Desired behavior
The order of the output css should not be altered from its original order in the scss. Everything would be fine in this specific use case if the border property had been added at the beginning of the selector, but I haven’t thought of other potential flaws here.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:9
Top Results From Across the Web
Ordering flex items - CSS: Cascading Style Sheets | MDN
In this article, we will take a look at ways in which you can change the visual order of your content when using...
Read more >Angular wrong css order in production build - Stack Overflow
I have a class which I defined in both files. When I serve the app with ng serve I see blue background (red...
Read more >How To Apply CSS Styles to HTML with Cascade and Specificity
Cascading Style Sheets, better known as CSS, is the language for visual style and design on the web. With it, you can apply...
Read more >A Few Different CSS Methods for Changing Display Order
In this tutorial we'll cover a few different CSS methods for reordering HTML elements. The Goal The layout we want to build is...
Read more >Hacking CSS in MadCap Flare
Use CSS Variables · Use CSS Comments · Avoid Local Styling when Possible · Use the Flare Stylesheet Editor · Summary · Related...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is expected since during production builds by default CSS gets minified to generate the smallest possible bundle and options get combined together using
cleancss
If you have some code which is not side effect free you need to disable the optimisations for that piece of code using
/* clean-css ignore:start */
and/* clean-css ignore:end */
commentsSee https://github.com/jakubpawlowicz/clean-css#whats-new-in-version-42
Is there any fix available related to this issue? Can’t get my css to work with ng build --prod --aot