-
Notifications
You must be signed in to change notification settings - Fork 918
Styles scoped by default? #698
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
Comments
LGTM |
I use |
I have never used CSS modules. How exactly is this different from scoped styles? |
Right so "A CSS Module is a CSS file in which all class names and animation names are scoped locally by default." Again, how exactly is this different from scoped styles? Sounds like this further improves my point. I disagree that using |
Descendent selector + recursive components with scoped style could be tricky. Also, it feels like
|
Making |
@znck do you happen to know why |
@jaredreich Aside from differences in implementation, practically I’ve found In other words, |
@znck what's an example of how "making |
@jaredreich Any normal (not
will change its behavior. Anyhow, making it by default adds extra indirection and makes picking up |
Thanks for the information all, guess the majority disagrees and has good points, closing! |
I just realized that we already have this ungodly power, in a way, using module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
html: 'WHATEVER PUG LOADER IS, maybe impossible because https://github.com/vuejs/vue-loader/blob/8f9524ae2996cb38c49698a645c26b860ed844e0/lib/template-compiler/preprocessor.js',
css: 'stylus-loader'
}
}
}
]
} Note, that this will shadow the default lang names instead of changing the default, so you would have to define your own "raw-html" lang and such if you wished to use it in some places. |
Is there a way to specify project defaults yet? I'd like to avoid writing |
@qm3ster If I use your |
I also like the concept behind "scoped", but your css file will be somewhat bloated. On my last project (without any css frameworks) after removing "scoped", css file lost 25% of it's weight. |
I think that scoped style should be the default, at least for single file components. I was extremely surprised to find that I was having class clashes in between different components. And given Due 3.x is a major version, I think that breaking many components is not so relevant :) Please let me know if we can reopen this issue or if I should fill another one. |
@falcon03 I don't think breaking changes will fly with this repo, but I think making I have a private repo with hundreds of components and never does it make sense for a component's styling to leak into the global space by default. Now I have to police the team to remember to put a |
The thing is .. you basically never want (or should want) to define global CSS in a component. Maybe in main.vue. So It's similar thing as explicit break in switch statement .. nonsense. There is like 5% againtst 95% cases where you want that behavior. Look at Go or Kotlin (when expression). |
Uh oh!
There was an error while loading. Please reload this page.
Perhaps this is a conceptual question rather than an issue. I find myself writing
scoped
for nearly every single component I make, except maybeApp
. Following web component standards logic, shouldn't a component's style be scoped by default? I feel like the side effects of styles being global by default are worse than scoped by default.Perhaps if this was implemented, a
global
attribute can be used in components that specifically intend to have their styles applied globally.Thoughts?
The text was updated successfully, but these errors were encountered: