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.

Using plugin "webpack.optimize.UglifyJsPlugin" led to remove the style "display: -webkit-flex;"

See original GitHub issue

Thank you to review the issue.

I using this plugin to compress js and css. I found an issue. It will remove the style “display: -webkit-flex;”.

The css file

.product-grid {
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-flow: wrap;
  flex-wrap: wrap;
  -ms-flex-line-pack: center;
  -webkit-align-content: center;
  align-content: center;
}

after webpack builded, the css will become

.product-grid {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  display: -webkit-flex;
  -webkit-flex-flow: wrap;
  flex-wrap: wrap;
  -ms-flex-line-pack: center;
  align-content: center
}

The result is it remove “display: -webkit-flex;”.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:11
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
warmbowskicommented, Jun 8, 2016

I need to strike my last post. When I upgraded from node 5 to node 6, I had to reinstall all of my node_modules, and I think it messed up my post-css autoprefixer config for {browsers: []}. So properly configuring that fixed most of the autoprefixing, except when running through UglifyJS webpack plugin.

I finally wrapped my head around the problem, though, and now I understand that when you use UglifyJSPlugin, it is only used to optimized the JS (of course), BUT simultaneously, using that plugin enables the minimize parameter on css-loader. This in turn enables cssnano in css-loader which has autoprefixing enabled by default. This autoprefixer overrides any postcss autoprifixer, and does not inherit the proper {browsers: []} configuration. So it doesn’t prefix properly. To disable the autoprefixer in css-loader and allow postcss to take over, you will need to add -autprefixer to the loader parameters. See this issue in postcss/autoprefixer for more info https://github.com/postcss/autoprefixer/issues/660

6reactions
stevewillardcommented, May 24, 2016

Are you sure this is related to UglifyJsPlugin. I mean, it is UglifyJsPlugin 😄

I had a similar problem where I was using cssnano as a PostCSS process. It turns out it aggressively removes things it shouldn’t. This is how I fixed it:

  postcss: function() {
    return [autoprefixer, cssnano({ safe: true })];
  },
Read more comments on GitHub >

github_iconTop Results From Across the Web

webpack.optimize.UglifyJsPlugin has been removed
I have tried adding the minimizer within Module exports in my webpack.config.prod.js file, as well as installing 'uglifyjs-webpack-plugin' ...
Read more >
Flexbox prefix not being compiled - sage - Roots Discourse
A bit of a strange one - when compiling for production a specific flexbox prefix: -webkit-flex seems to be being ignored.
Read more >
UglifyjsWebpackPlugin | webpack
This plugin uses uglify-js to minify your JavaScript. Requirements. This module requires a minimum of Node v6.9.0 and Webpack v4.0.0. Getting Started.
Read more >
v4.5.10 Release Notes | Documentation - ServiceStack Docs
In production builds, .css files are written using ExtractTextPlugin and the resulting .js files minified with UglifyJS. The CopyWebpackPlugin is then used ...
Read more >
解决webpack编译后导致-webkit-box被强制去除了的问题
issue3: # Using plugin “webpack.optimize.UglifyJsPlugin” led to remove the style “display: -webkit-flex;. 觉得略坑。还是花了大概一下午看这个问题 ...
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