Jim Lynch Codes
  • Blog
  • About Jim

Writings about one coder's stories & experiences.

The Gulp cssnano z-index Bug and How to Fix It

6/4/2016

0 Comments

 
One of the things I really hate is when my application running in gulp serve looks totally different from the application running with gulp serve:dist. The second one does a production build and then runs that, and sometimes with the minification and concatenation things gets messed up (usually it's that dang css). Anyway, this post is about how I fixed the z-index issue that is related to this.

The Problem

The problem is that cssnano (one of the plugins in the build step of the Gulp-Angular generated project) was actually changing the z-index values in the css! For example, in my code I would give something a z-index of 300. It would have that z-index when I select the element with the chrome dev tools inpector when running gulp serve, but when running gulp serve:dist it would change the z-index to something weird like 16. This would have been such a big deal if it kept the order of everything as I had it, but some things were in front of things that shouldn't have been so it just looked terrible. 

The Solution

The first part of the solution is to realize that is the "cssnano" step in your build process that it causing the problems here. Then you need to change the code to have it ignore z-indices. I followed the advice from the github issue thread here and here. Basically, it comes down to this:
In the file for your gulp build task (gulp-angular names it build.js) you simply update this line of code:
 .pipe($.cssnano())
to look like this:
 .pipe($.cssnano({zindex: false}))
And then you're golden! :)
0 Comments

Your comment will be posted after it is approved.


Leave a Reply.

    ​Author

    Picture
    The posts on this site are written and maintained by Jim Lynch. About Jim...
    Follow @JimLynchCodes
    Follow @JimLynchCodes

    Categories

    All
    Actionscript 3
    Angular
    AngularJS
    Automated Testing
    AWS Lambda
    Behavior Driven Development
    Blockchain
    Blogging
    Business Building
    C#
    C / C++
    ClojureScript / Clojure
    Coding
    Community Service
    CS Philosophy
    Css / Scss
    Dev Ops
    Firebase
    Fitness
    Flash
    Front End
    Functional Programming
    Git
    Go Lang
    Haskell
    Illustrations
    Investing
    Java
    Javascript
    Lean
    Life
    Linux
    Logic Pro
    Music
    Node.js
    Planning
    Productivity
    Professionalism
    Python
    React
    Redux / Ngrx
    Refactoring
    Reusable Components
    Rust
    Security
    Serverless
    Shell Scripting
    Swift
    Test Driven Development
    Things
    TypeScript
    Useful Sites
    Useful Tools
    Video
    Website Development
    WebStorm
    Writing

    Archives

    August 2021
    February 2021
    January 2021
    October 2020
    September 2020
    May 2020
    April 2020
    February 2020
    January 2020
    December 2019
    October 2019
    September 2019
    August 2019
    July 2019
    June 2019
    May 2019
    April 2019
    March 2019
    February 2019
    January 2019
    December 2018
    November 2018
    October 2018
    September 2018
    August 2018
    June 2018
    May 2018
    April 2018
    March 2018
    February 2018
    January 2018
    December 2017
    November 2017
    October 2017
    September 2017
    August 2017
    July 2017
    May 2017
    April 2017
    March 2017
    February 2017
    January 2017
    December 2016
    November 2016
    October 2016
    September 2016
    August 2016
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016
    February 2016
    January 2016
    December 2015
    November 2015
    October 2015

    RSS Feed

  • Blog
  • About Jim
JimLynchCodes © 2021