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

Setting style.scoped to true / false in Vue options has no effect #7832

Closed
7 tasks done
pmk1c opened this issue Apr 20, 2022 · 3 comments · Fixed by #8994
Closed
7 tasks done

Setting style.scoped to true / false in Vue options has no effect #7832

pmk1c opened this issue Apr 20, 2022 · 3 comments · Fixed by #8994

Comments

@pmk1c
Copy link

pmk1c commented Apr 20, 2022

Describe the bug

When I set style.scoped: true in Vue plugin options, I would have expected, that all SFCs would now use scoped styles. But it does not seem to have any effect.

The same goes for setting style.scoped: false. I would have expected, it overrides SFCs, that explicitly set style scoped, not to use scoped styles.

I think the bug (if it is one and not intended) is, that block.scoped always overrides style.scoped here: https://github.com/vitejs/vite/blob/main/packages/plugin-vue/src/style.ts#L25

Reproduction

https://stackblitz.com/edit/vitejs-vite-oiw3bg?file=vite.config.js

System Info

System:
    OS: macOS 12.2.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 33.63 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.14.2 - ~/.asdf/installs/nodejs/16.14.2/bin/node
    npm: 8.5.0 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Chrome: 100.0.4896.127
    Firefox: 98.0.2
    Safari: 15.3
  npmPackages:
    @vitejs/plugin-vue: * => 2.3.1 
    vite: * => 2.9.1

Used Package Manager

npm

Logs

No response

Validations

@haoqunjiang
Copy link
Member

From the design perspective, I wouldn't want Vue users to be able to set the scoped flag globally via a plugin option.

What's the use case here?

@pmk1c
Copy link
Author

pmk1c commented Apr 21, 2022

I get that, but when I found the option, I was thinking, that's what it does... So the other option would be, to get rid of the option, I think.

My use case is quite special: We're building a Vue App with Vite using scoped Styles in components. Everythings fine here.
Now we need to build a Static Generated HTML-Page to put into some weird HTML-like content tool in Salesforce, which for some completely unknown reason removes all data-v- attributes when serving this HTML-like content and therefore breaks scoped styles. For this weird build case, we want to use our existing components, but not scope the styles.

I don't know if I'd count this as a valid use-case, if I maintained Vite. 😉
I wouldn't even have thought, that such an option existed if I hadn't found it.

@pmk1c
Copy link
Author

pmk1c commented Apr 22, 2022

I found another work-around for our weird problem. I get why this feature would be weird. So I think it's completely fine if you decide you don't want that. In that case, I'd still remove the option from the types then.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants