Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit eaf0fe5

Browse files
fix(build): partition IE-only CSS fixes during build
Media query with \0 causing parsing issues with node-sass and LESS. * Move all IE fixes to raw CSS. Append to generated CSS during builds. Fixes #6304
1 parent 6c42ac7 commit eaf0fe5

File tree

5 files changed

+111
-18
lines changed

5 files changed

+111
-18
lines changed

gulp/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ module.exports = {
4040
'src/components/**/*.scss',
4141
'src/core/services/**/*.scss'
4242
],
43+
cssIEPaths : 'src/**/ie_fixes.css',
4344
paths: 'src/{components, services}/**',
4445
outputDir: 'dist/',
4546
demoFolder: 'demo-partials'

gulp/tasks/build-scss.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var sassUtils = require('../../scripts/gulp-utils');
1212
var sass = require('gulp-sass');
1313
var minifyCss = require('gulp-minify-css');
1414
var insert = require('gulp-insert');
15+
var addsrc = require('gulp-add-src');
1516
var gulpif = require('gulp-if');
1617
var args = util.args;
1718
var IS_DEV = require('../const').IS_DEV;
@@ -31,6 +32,7 @@ exports.task = function() {
3132
streams.push(
3233
scssPipe = gulp.src(getPaths())
3334
.pipe(util.filterNonCodeFiles())
35+
.pipe(filter(['**', '!**/*.css']))
3436
.pipe(filter(['**', '!**/*-theme.scss']))
3537
.pipe(filter(['**', '!**/*-print.scss']))
3638
.pipe(filter(['**', '!**/*-attributes.scss']))
@@ -41,11 +43,11 @@ exports.task = function() {
4143
streams.push(
4244
scssPipe
4345
.pipe(sass())
44-
.pipe(rename({extname: '.css'})) // unminified
45-
.pipe(rename({ basename: filename }))
4646
.pipe(util.autoprefix())
4747
.pipe(insert.prepend(config.banner))
48-
.pipe(gulp.dest(dest))
48+
.pipe(addsrc.append(config.cssIEPaths)) // append raw CSS for IE Fixes
49+
.pipe(concat('angular-material.css'))
50+
.pipe(gulp.dest(dest)) // unminified
4951
.pipe(gulpif(!IS_DEV, minifyCss()))
5052
.pipe(rename({extname: '.min.css'}))
5153
.pipe(gulp.dest(dest)) // minified

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"esprima": "^1.2.2",
3636
"glob": "~4.0.2",
3737
"gulp": "^3.9.0",
38+
"gulp-add-src": "^0.2.0",
3839
"gulp-autoprefixer": "^1.0.1",
3940
"gulp-concat": "^2.2.0",
4041
"gulp-connect": "^2.2.0",
@@ -80,4 +81,3 @@
8081
"squash": "git rebase -i $(npm run -s merge-base)"
8182
}
8283
}
83-

src/core/services/layout/ie_fixes.css

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/* IE mediaQuery hack for 8,9,10 to set the flex-basis properly for 'flex' values */
2+
/* Details: */
3+
/* Do not use unitless flex-basis values in the flex shorthand because IE 10-11 will error. */
4+
/* Also use 0% instead of 0px since minifiers will often convert 0px to 0 (which is unitless and will have the same problem). */
5+
/* Safari, however, fails with flex-basis : 0% and requires flex-basis : 0px */
6+
7+
@media screen\0 {
8+
.flex {
9+
-webkit-flex: 1 1 0%;
10+
-ms-flex: 1 1 0%;
11+
flex: 1 1 0%;
12+
}
13+
}
14+
15+
@media screen\0 {
16+
.flex {
17+
-webkit-flex: 1 1 0%;
18+
-ms-flex: 1 1 0%;
19+
flex: 1 1 0%;
20+
}
21+
}
22+
23+
@media screen\0
24+
and (max-width: 599px) {
25+
.flex-xs {
26+
-webkit-flex: 1 1 0%;
27+
-ms-flex: 1 1 0%;
28+
flex: 1 1 0%;
29+
}
30+
}
31+
32+
@media screen\0
33+
and (min-width: 600px) {
34+
.flex-gt-xs {
35+
-webkit-flex: 1 1 0%;
36+
-ms-flex: 1 1 0%;
37+
flex: 1 1 0%;
38+
}
39+
}
40+
41+
@media screen\0
42+
and (min-width: 600px) and (max-width: 959px) {
43+
.flex-sm {
44+
-webkit-flex: 1 1 0%;
45+
-ms-flex: 1 1 0%;
46+
flex: 1 1 0%;
47+
}
48+
}
49+
50+
@media screen\0
51+
and (min-width: 960px) {
52+
.flex-gt-sm {
53+
-webkit-flex: 1 1 0%;
54+
-ms-flex: 1 1 0%;
55+
flex: 1 1 0%;
56+
}
57+
}
58+
59+
@media screen\0
60+
and (min-width: 960px) and (max-width: 1279px) {
61+
.flex-md {
62+
-webkit-flex: 1 1 0%;
63+
-ms-flex: 1 1 0%;
64+
flex: 1 1 0%;
65+
}
66+
}
67+
68+
@media screen\0
69+
and (min-width: 1280px) {
70+
.flex-gt-md {
71+
-webkit-flex: 1 1 0%;
72+
-ms-flex: 1 1 0%;
73+
flex: 1 1 0%;
74+
}
75+
}
76+
77+
@media screen\0
78+
and (min-width: 1280px) and (max-width: 1919px) {
79+
.flex-lg {
80+
-webkit-flex: 1 1 0%;
81+
-ms-flex: 1 1 0%;
82+
flex: 1 1 0%;
83+
}
84+
}
85+
86+
@media screen\0
87+
and (min-width: 1920px) {
88+
.flex-gt-lg {
89+
-webkit-flex: 1 1 0%;
90+
-ms-flex: 1 1 0%;
91+
flex: 1 1 0%;
92+
}
93+
}
94+
95+
@media screen\0
96+
and (min-width: 1920px) {
97+
.flex-xl {
98+
-webkit-flex: 1 1 0%;
99+
-ms-flex: 1 1 0%;
100+
flex: 1 1 0%;
101+
}
102+
}
103+
104+

src/core/style/layout.scss

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,6 @@
117117

118118
.#{$flexName} { flex: 1; box-sizing: border-box; } // === flex: 1 1 0%;
119119

120-
// IE mediaQuery hack for 8,9,10 to set the flex-basis properly for 'flex' values
121-
// Details:
122-
// Do not use unitless flex-basis values in the flex shorthand because IE 10-11 will error.
123-
// Also use 0% instead of 0px since minifiers will often convert 0px to 0 (which is unitless and will have the same problem).
124-
// Safari, however, fails with flex-basis : 0% and requires flex-basis : 0px
125-
@if $name != '-print' {
126-
@media screen\0 {
127-
.#{$flexName} {
128-
flex: 1 1 0%;
129-
}
130-
}
131-
}
132-
133-
134120
.#{$flexName}-grow { flex: 1 1 100%; box-sizing: border-box; }
135121
.#{$flexName}-initial { flex: 0 1 auto; box-sizing: border-box; }
136122
.#{$flexName}-auto { flex: 1 1 auto; box-sizing: border-box; }

0 commit comments

Comments
 (0)