Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Possibility to use scoped styles #34

Open
selenecodes opened this issue Jan 14, 2018 · 6 comments
Open

Possibility to use scoped styles #34

selenecodes opened this issue Jan 14, 2018 · 6 comments

Comments

@selenecodes
Copy link

Hey, first of all awesome work on this template!
I was wondering if there will be support for scoped styles in the future?
Because *.vue files already natively support <style scoped src="./nameOfComponent.scss"></style>.
I mean I love the way the import "./nameOfComponent.scss" works but maybe add styles as a component parameter just like template.

Proposed idea:

@Component({
    template: require('./home.html'),
    styleUrls: [ './home.scss', './secondHomeStyles.scss' ] //how angular2 does it
})

or this way

@Component({
    template: require('./home.html'),
    style: require('./home.scss') //an approach more similar to the template.
})

I don't know if this is at all feasible or if there's already a workaround that doesn't involve switching to vue files.

@ducksoupdev
Copy link
Owner

ducksoupdev commented Jan 16, 2018

Hi, thanks for the compliment :)

In terms of scoped styles, I have used CSS modules in a React app with PostCSS and Webpack. It should fit nicely and provide what is needed. It won't be the same style as *.vue files but should have the same result.

There is a nice article on it here https://medium.com/@kswanie21/css-modules-sass-in-create-react-app-37c3152de9

Happy to investigate or leave it up to you to create a PR?

@selenecodes
Copy link
Author

Oh thanks, will look into it!
If I get a working implementation I'll make a PR for it.

@arihantdaga
Copy link

I used something old style...
in my scss files i wrote

[data-comp="home"]{
    p {
          coolor: red
    }
}

and in my component's outer tag-

<div data-comp="home"></div>

Is this good ??

@ducksoupdev
Copy link
Owner

I have created a spike repo to show how it could work with this template - ducksoupdev/vue-webpack-typescript-css-modules@f4c57e6...a406361

If this is what you are looking for @joostblok I can add it to the template?

@ducksoupdev
Copy link
Owner

See discussion at css-modules/css-modules#65.

The above repo is an implementation that contains two loader configurations for .scss files. This is to explicitly separate CSS modules from global CSS files.

@admhemed
Copy link

Hi, I used ducksoupdev/vue-webpack-typescript-css-modules@f4c57e6...a406361
and it is successfully work,
but css stopped to reload properly,
it reloads, but it brings the old css instead of the new one,
what can I do to fix that?

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

No branches or pull requests

4 participants