latest[mybe not just]
[zIndexBug.zip](https://github.com/vuejs-templates/webpack/files/858212/zIndexBug.zip)
npm run dev锛宔verything fineI think the z-index value shouldn't be changed锛宐ecause we may use the third party plugin like jQuery plugin which could use z-index. In this condition, the z-index calculation is unnecessary, and make mistakes.
keep my z-index value

my z-index changed

You likely set the same class somewhere else, with z-index: 1
During production, all CSS is extracted in one file and minified, which also removes duplicate definitions - and in this case, the duplicate with z-index: 1 was the "survivor".
No, absolutely not.
I just want to override z-index that setted in other plugin.
For example, I set z-index: 2 in a.js, then I import it at b.js, and override z-index: 3 in b.js, it wouldn't work.
For example, I set
z-index: 2ina.js, then I import it atb.js, and overridez-index: 3, it wouldn't work.
This is exactly what I am talking about, though. If you override global styles in a component without using the scopedfeature, the latest one will override all other versions. CSS is global by default.
If you still disagree, please provide a repository with a minimal reproduction for me to check out.
I write a simple demo.
npm run dev: You will see the blue skynpm run build: You will see the tan landMaybe you would ask why set
z-indexin the DOM, because we cannot guarantee what component will be used. It just like using a component doesn't write with Vue.
Just run into the same problem. In my single .vue file, I set the modal-mask 'z-index:999', and alert 'z-index:1000' (both in scoped style tag)

After building, they are changed into 1 and 2.

I think it is the same issue as : https://github.com/ben-eb/gulp-cssnano/issues/8
Since I search in the node_modules folder and find cssnano installed.

Ah I see, so at the root, this is an issue with css-loader / cssnano default settings.
I think we should be able to fix this in the webpack config for css-loader.
Thanks for investigating! :)
Hm, I'm currently trying to test my fix, but I can't reproduce the problematic behaviour, even if I set minimize: { zindex: true } in the css-loader's options...
I noticed that the webpack/template/build/webpack.prod.conf.js file has been changed by yyx990803.
So everything goes well. By the way, thanks.
Oh, I missed that, thanks for the pointer!
@LinusBorg should this be added in the Readme.md file as well.
new OptimizeCssAssetsPlugin({
cssProcessorOptions: {
safe: true
}
}),
Most helpful comment
I noticed that the
webpack/template/build/webpack.prod.conf.jsfile has been changed by yyx990803.So everything goes well. By the way, thanks.