question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Minification of CSS in -p mode removes -moz/-o/-ms rules

See original GitHub issue

I was testing out Webpack with the -p flag and got some weird results in my CSS compared to my regular page. One of these errors was the aparent removal of CSS code.

CSS in my .css-file:

.systembar::before {
  background: #0066b3;
  background: -o-linear-gradient(left, #a2c517 10%, #009046 30%, #0082b6 50%, #151f77 75%, #db0050 100%);
  background: -moz-linear-gradient(left, #a2c517 10%, #009046 30%, #0082b6 50%, #151f77 75%, #db0050 100%);
  background: -webkit-linear-gradient(left, #a2c517 10%, #009046 30%, #0082b6 50%, #151f77 75%, #db0050 100%);
  background: -ms-linear-gradient(left, #a2c517 10%, #009046 30%, #0082b6 50%, #151f77 75%, #db0050 100%);
  background: -webkit-gradient(linear, left top, right top, color-stop(0.1, #a2c517), color-stop(0.3, #009046), color-stop(0.5, #0082b6), color-stop(0.75, #151f77), color-stop(1, #db0050));
  background: linear-gradient(left, #a2c517 10%, #009046 30%, #0082b6 50%, #151f77 75%, #db0050 100%);
}

After inspecting the ::before object in Firefox:

{
    background: #0066b3;
    background: -webkit-linear-gradient(left,#a2c517 10%,#009046 30%,#0082b6 50%,#151f77 75%,#db0050);
    background: -webkit-gradient(linear,left top,right top,color-stop(.1,#a2c517),color-stop(.3,#009046),color-stop(.5,#0082b6),color-stop(.75,#151f77),color-stop(1,#db0050));
    background: linear-gradient(left,#a2c517 10%,#009046 30%,#0082b6 50%,#151f77 75%,#db0050);
}

This is of course not matched to Firefox, and the background becomes blue instead of gradient

It seems that the minification done by -p removed the Firefox/Opera/IE-specific lines, and kept only the Wekbit parts. Why is this done, and how can I prevent this bug?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
SimenBcommented, Mar 12, 2016

adding -autoprefixer as an option to css-loader fixes this in our case. We use autoprefixer ourselves to manually add support for stuff for quite old IEs and Chromes, which cssnano removed

0reactions
robinsvingcommented, Mar 16, 2016

Moved issue here though it was already answered by @SimenB in this issue. Closing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Minification of CSS in -p mode removes -moz/-o/-ms rules #248
Copied from webpack issue#2158 I was testing out Webpack with the -p flag and got some weird results in my CSS compared to...
Read more >
The complete best practices for minifying CSS - LogRocket Blog
Minifying CSS files is more nuanced than you might think at first. Learn the various minification tools, how to determine and remove unused ......
Read more >
Minify CSS – CSS Minifying and Compression Explained
The goal of minification is to remove the parts of your CSS code that are irrelevant to the browser to interpret the CSS....
Read more >
What is Minification | Why minify JS, HTML, CSS files - Imperva
Minification is the process of minimizing code and markup in your web pages and script files. It's one of the main methods used...
Read more >
Bundling and Minification | Microsoft Learn
Minification performs a variety of different code optimizations to scripts or css, such as removing unnecessary white space and comments and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found