Skip to content

Commit

Permalink
Merge pull request #2817 from cfpb/fix_for_css_size
Browse files Browse the repository at this point in the history
Fix for styles rendering in IE9
  • Loading branch information
sebworks authored Mar 30, 2017
2 parents d38f40c + 2ecf751 commit cb923f0
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 93 deletions.
5 changes: 3 additions & 2 deletions cfgov/jinja2/v1/_layouts/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@
-->

{% block css %}
<!--[if lt IE 9]> <link rel="stylesheet" href="{{ static('css/main.ie.css') }}"> <![endif]-->
<!--[if gt IE 8]><!--> <link rel="stylesheet" href="{{ static('css/main.css') }}"> <!--<![endif]-->
<!--[if lt IE 9]><link rel="stylesheet" href="{{ static('css/main.ie8.css') }}"><![endif]-->
<!--[if IE 9]><link rel="stylesheet" href="{{ static('css/main.ie9.css') }}"><![endif]-->
<!--[if gt IE 9]><!--><link rel="stylesheet" href="{{ static('css/main.css') }}"><!--<![endif]-->
{% endblock css %}

<!--
Expand Down
2 changes: 1 addition & 1 deletion gulp/tasks/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function scriptsPolyfill() {
} ) )
.pipe( gulpUglify( {
compress: {
properties: false
properties: false
}
}) )
.pipe( gulpRename( 'modernizr.min.js' ) )
Expand Down
34 changes: 31 additions & 3 deletions gulp/tasks/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var gulpRename = require( 'gulp-rename' );
var gulpSourcemaps = require( 'gulp-sourcemaps' );
var handleErrors = require( '../utils/handle-errors' );
var mqr = require( 'gulp-mq-remove' );
var gulpBless = require( 'gulp-bless' );

/**
* Process modern CSS.
Expand All @@ -40,11 +41,36 @@ function stylesModern() {
} ) );
}

/**
* Process legacy CSS for IE9 only.
* @returns {PassThrough} A source stream.
*/
function stylesIE9() {
return gulp.src( configStyles.cwd + configStyles.src )
.pipe( gulpLess( configStyles.settings ) )
.on( 'error', handleErrors )
.pipe( gulpAutoprefixer( {
browsers: [ 'ie 9' ]
} ) )
.pipe( gulpRename( {
suffix: '.ie9',
extname: '.css'
} ) )
.pipe( gulpCleanCss( {
compatibility: 'ie9',
inline: ['none']
} ) )
.pipe( gulp.dest( configStyles.dest ) )
.pipe( browserSync.reload( {
stream: true
} ) );
}

/**
* Process legacy CSS for IE7 and 8 only.
* @returns {PassThrough} A source stream.
*/
function stylesIe() {
function stylesIE8() {
return gulp.src( configStyles.cwd + configStyles.src )
.pipe( gulpLess( configStyles.settings ) )
.on( 'error', handleErrors )
Expand All @@ -57,7 +83,7 @@ function stylesIe() {
// mqr expands the minified file
.pipe( gulpCleanCss( { compatibility: 'ie8' } ) )
.pipe( gulpRename( {
suffix: '.ie',
suffix: '.ie8',
extname: '.css'
} ) )
.pipe( gulp.dest( configStyles.dest ) )
Expand Down Expand Up @@ -215,7 +241,8 @@ function stylesNemoIE() {
}

gulp.task( 'styles:modern', stylesModern );
gulp.task( 'styles:ie', stylesIe );
gulp.task( 'styles:stylesIE8', stylesIE8 );
gulp.task( 'styles:stylesIE9', stylesIE9 );
gulp.task( 'styles:ondemand', stylesOnDemand );
gulp.task( 'styles:featureFlags', stylesFeatureFlags );
gulp.task( 'styles:knowledgebase', stylesKnowledgebaseProd );
Expand All @@ -226,6 +253,7 @@ gulp.task( 'styles:nemo', [
'styles:nemoProd',
'styles:nemoIE'
] );
gulp.task( 'styles:ie', ['styles:stylesIE8', 'styles:stylesIE9'] );

gulp.task( 'styles', [
'styles:modern',
Expand Down
Loading

0 comments on commit cb923f0

Please sign in to comment.