Skip to content
New issue

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

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

Already on GitHub? # to your account

How to use with-external-scoped-css example with SCSS #3053

Closed
aviramga opened this issue Oct 8, 2017 · 10 comments
Closed

How to use with-external-scoped-css example with SCSS #3053

aviramga opened this issue Oct 8, 2017 · 10 comments

Comments

@aviramga
Copy link

aviramga commented Oct 8, 2017

Hi,

I'm working with the with-external-scoped-css example and would like to covert the sass to scss. I've updated the .bablerc file to include scss but the bundle.css appears to be empty.

Could someone please help me with the exact steps to convert it to scss?
I've already looked at the other css related examples (including the global one) but I would really like to keep the scoped css solution.

Im using Next v4-beta.4
Thanks for the help!

@aviramga aviramga changed the title Using the with-external-scoped-css with SCSS How to use with-external-scoped-css example with SCSS Oct 8, 2017
@timneutkens
Copy link
Member

cc @guidiego

@guidiego
Copy link

guidiego commented Oct 8, 2017

@aviramga did you change the pre-processor.js??

https://github.com/zeit/next.js/blob/7c908633cbdfcd158bf50c60cee16474948efdbd/examples/with-external-scoped-css/.babelrc#L3:L12

You can remove this line: "preprocessCss": "./pre-processor.js" or change the indentedSyntax: true to false!

@aviramga
Copy link
Author

aviramga commented Oct 8, 2017

Works!!! THANK YOU! @guidiego !

Can you please explain why this works? I hate it to stay in the "magic" level :)

Also, I cannot use fixed class names? (i.e className="some-class" ) and just use the same class name in my scss file?

@timneutkens
Copy link
Member

Going to close this, but @guidiego can most likely explain 😄

@aviramga
Copy link
Author

aviramga commented Oct 8, 2017

Cool thanks! @guidiego please help :)

@timneutkens
Copy link
Member

@aviramga Also be sure to join https://zeit.chat 😄

@guidiego
Copy link

guidiego commented Oct 8, 2017

@aviramga Gonna go in parts:

This example works with any pre-processor, the pre-processor.js file is used as a parser for you .anything files :)

The babel-plugin used to make this example works fine with SCSS and LESS without a necessity to create/use the pre-processor.js file, at least, I prefer to create this example to illustrate the possibility to make complex things. So this works because SCSS is the base language (as less) of this plugin :D When you remove the pre-processor and add the .scss files in pattern this will work as you expect. The other approach (indentedSyntax: true), is because the sass-core use it to understand if you want to work with a processor based on indent (sass) or the default (scss).

Also, I cannot use fixed class names? (i.e className="some-class" ) and just use the same class name in my scss file?

Yeap, for what I remember (I use some plugins) you can add a :global{ ... } in it and add it to the processor to be appended with the other stuff 🤔

CC: @timneutkens I opened a PR for link this issue in my example with a better explanation :)

@aviramga
Copy link
Author

aviramga commented Oct 8, 2017

Thanks @guidiego for the amazing explanation!

Where did you get the :global tip from? Also, is there a way to fix the hot-reload issue?

@chhuang
Copy link

chhuang commented Oct 16, 2017

@aviramga :global is from CSS Modules.

:global switches to global scope for the current selector respective identifier.

Maybe we need an example without CSS Modules.

@lock
Copy link

lock bot commented May 10, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants