Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After built the z-index changed #614

Closed
Roamin opened this issue Mar 21, 2017 · 10 comments
Closed

After built the z-index changed #614

Roamin opened this issue Mar 21, 2017 · 10 comments
Assignees

Comments

@Roamin
Copy link

Roamin commented Mar 21, 2017

Version

latest[mybe not just]
zIndexBug.zip

Steps to reproduce

  • Just make a vue component,write z-index in style
  • Run command: npm run dev,everything fine
  • Run command: 'npm run build`,what a mess...my z-index value changed

I think the z-index value shouldn't be changed,because 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.

What is expected?

keep my z-index value
dev

What is actually happening?

my z-index changed
built

@LinusBorg
Copy link
Contributor

LinusBorg commented Mar 29, 2017

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".

@Roamin
Copy link
Author

Roamin commented Mar 30, 2017

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.

@LinusBorg
Copy link
Contributor

For example, I set z-index: 2 in a.js, then I import it at b.js, and override z-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.

@Roamin
Copy link
Author

Roamin commented Mar 30, 2017

I write a simple demo.

  • npm run dev: You will see the blue sky
  • npm run build: You will see the tan land

Maybe you would ask why set z-index in the DOM, because we cannot guarantee what component will be used. It just like using a component doesn't write with Vue.

zIndexBug.zip

@LinusBorg LinusBorg self-assigned this Mar 30, 2017
@Vivi-wu
Copy link

Vivi-wu commented Mar 31, 2017

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)
2

After building, they are changed into 1 and 2.
1
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.
3

@LinusBorg
Copy link
Contributor

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! :)

@LinusBorg
Copy link
Contributor

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...

@Roamin
Copy link
Author

Roamin commented Apr 10, 2017

I noticed that the webpack/template/build/webpack.prod.conf.js file has been changed by yyx990803.

only use safe optimizations for css minification

So everything goes well. By the way, thanks.

@LinusBorg
Copy link
Contributor

Oh, I missed that, thanks for the pointer!

JulienMelissas added a commit to roots/sage that referenced this issue Jun 6, 2017
I was running into some issues on production builds with z-indexes as well as a few more advanced background gradients, etc. [This issue](vuejs-templates/webpack#614) linked to a solution I thought I should try which fixed it right away. By default I think this should be included in all builds.
@jahanzaibsuleman07
Copy link

@LinusBorg should this be added in the Readme.md file as well.

new OptimizeCssAssetsPlugin({
          cssProcessorOptions: {
            safe: true
          }
        }),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants