-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Optional Sass Support #78
Comments
I'm not sure we want to make anything optional, in the sense of having people choose between multiple options. We went down that route for What you have in |
I see where you’re coming from but I’d like to learn more about your use case for Less / SASS in React. With components and a BEM-like convention, many their features are actually not that useful. The only one I can think of that I’m truly missing in this setup is the ability to share constants across files. This is useful e.g. for color themes. But there is an escape hatch even for this: you can use JavaScript styles (or just inline styles) and then import those values. What other features are you missing? |
So how is this project useful if you still have to add these things to ease your development? |
Perhaps just adding recipes or documentation for various customizations, like Sass or test runners, using the This would help beginners (like me) be able to step their way to something more complicated. |
We’re sorry if it’s not useful to you yet. We think that many people learning React would appreciate even the current feature set. Please let’s keep this issue focused on Less/SASS, not on other issues. You can discuss testing in #80. Hot reloading of components won’t be supported until I figure out how to make it more stable (I’m the author of React Hot Loader). I fully intend to work on this, but there are more pressing issues. Thanks! |
@appjitsu This project isn't made for you then—it's just the basics to get started with a basic web app for demos and learning the basics of React. This isn't There's plenty of awesome projects in that vein like @mxstbr's boilerplate. The simplicity of this project is the best part about it. |
Sorry. Don't take my comments as being rude. I think this is a fantastic project. Although, I do view each of those features to be critical for ease of development.
|
Well OK then! Thanks! 😄
|
@appjitsu Didn't mean to sound like I thought you were rude, sorry 😄 Those features are definitely awesome for development and production, but this is for learning and demos (for now at least). Give it some time. |
^^ good discussion but let’s focus on Less/SASS in the future comments 😉 |
SASS would be awesome to have available. I absolutely would have used it today for a project had SASS been available. |
My issue is that if you allow Sass, you'll get "where's PostCSS/Sylus!?!?!?!". It's a can of worms you have to open carefully. |
@thecodegoddess What features of SASS do you use most often that you miss in regular CSS? |
@gaearon It's more that is what our current architecture is using. I know that you can get away with PostCSS for much as well. Mostly, we have variables and mixins that we are currently using. |
It would be great to have option from the cli when you first create the project. Similar to yeoman generators.
|
Sure, adding a flag ( |
This makes sense, thanks. For now we want to focus on making this useful for new projects because there are all sorts of conventions in old codebases that would be tricky to support. But I agree we need some solution for variables (postcss or otherwise).
Yep. Not adding flags or configuration options is a hard constraint of this project in the coming months. We might revisit this later. |
I know people in the SASS / LESS camps might not be too supportive of this, but here goes. This project currently uses Babel to ensure that all ES2015 and ES2016 features are supported. So, were ensuring that we the latest JS standards even though the browser support may not be there. So why not take the same approach with CSS and add officially add support for css-next? |
I thought about css-next but there’s a lot of stuff there. The direction seems valid though. The most conservative thing we could do is add support just for variables. But obvious we’d need imports too. Whatever we add, it needs to be rock-stable. I’m worried about issue lists like this: https://github.com/postcss/postcss-import/issues. |
I can see in the documentation that it says "currently not supported". Is there a plan to add that or the idea is just to eject and customise it after? I'll be glad to help on finding a solution if the decision is not yet clear. |
We want to wait and see, and most of all we want to understand what problems people are solving with Less/SASS in new React apps today. Perhaps there are other, easier solutions. |
I understand your concerns, but in my case sass it's a default. It's not about solving a particular problem, It's just part of my workflow. Just to be clear, maybe the purpose of this tool is not to address every case, but it looks so clean and cool that it saddens me I have to eject and pollute the whole app just to get sass support. I'll be following the development of this tool either way because I think it's great. Thanks. |
Got it, thanks for your perspective. We understand people might be used different tools, but we can’t implement support for them just because of that, as we wouldn’t have good rationales for why some tools are supported and some are not. Then we have 10 different supported tools, and we aren’t sure if they all work, and we need to do a lot of extra work if some underlying tech (like bundler) changes. I hope this gives you some perspective on why we’d rather avoid adding anything that can be solved by existing means. |
There is a project called React Bootstrap, does it use either? cc @taion We shouldn't just do something because Bootstrap does it. Components change how you think about modularising UI quite a lot. So constraints in which Bootstap is operating are not the same as constraints you meet developing React apps. You should be able to use Bootstrap in React projects, sure. This doesn't mean that something that "won" for Bootstrap is necessary for a React project. PS I would like further messages in this thread to focus solely on features of Less/SASS that you feel components + CSS don't solve well. Let's not just argue "what is better" because it doesn't help us to make any decisions. Thanks. |
Obviously. And it would be pointless to list the benefits of one or another here. That is well documented all over the internets. My point was that if you were to choose one preprocessor, SASS is the clear "winner", because of adoption. If facebook doesn't want to choose, then let us choose. |
React-Bootstrap just provides React components. We don't ship any of the styling. In cases where I use React-Bootstrap, I pull in Bootstrap via npm, and use But if you want to talk more broadly about Less, Sass, or cssnext, my feedback would be:
Given all that, my recommendation would be to bundle Sass support. I don't think the PostCSS-based ecosystem is sufficiently mature to offer a good option in the context of a project aimed at developers who want an easy way to get started. |
Ah, got it, thanks for clarifying. |
And I'd be totally fine with pointing users of React-Bootstrap at bootstrap-sass instead of the Less version if they're trying to use React-Bootstrap with create-react-app. |
Thank you very much for the context, this was super helpful. We’ll keep this in mind, and will be referencing this issue when making decisions in the future. |
Pardon the logorrhea on my part – on PostCSS, to summarize, we've found the stability just fine. The issue instead is that with the cssnext stuff, it's very easy to write CSS that is badly broken per spec but will right now get processed into something that works. This is fine for advanced users that are willing to go the extra mile to make sure they're not writing spec-incompliant CSS that still happens to work in cssnext, but to me seems extremely dangerous for general use – like a repeat of the Babel 5 decorator thing, but worse. |
First off I would love to have Sass support out of the box. Adding a loader doesn't opt anyone into using Sass - if a Sass file exist it gets parsed. Looking at this post from @tylermcginnis https://medium.freecodecamp.com/create-react-app-and-the-future-of-creating-react-applications-3c336f29bf1c#.qky3g94y1 very small sample but the CSS comments are both questions about using Sass. That said as for Less, Stylus others (likely Sass as well ... ) can they be supported via PostCss? I have an issue open here tweaking the plugin setup for PostCSS that would handle these cases |
We haven’t made any final decisions here. It’s just that we think this is currently out of scope, and we want to come back to this when we have time to look at CSS in React more holistically. In the meantime you can always use a console SASS tool that outputs |
I think this might be a good place to consider adding some customizability. Ultimately, the choice of CSS framework is mostly orthogonal to the tooling complexity in setting up React. I think giving a very limited set of choices for mostly orthogonal things like the choice of CSS framework would be a value-add here. |
I have to say I don't really like the idea that SASS isn't being considered "just because people use it." I fully understand that you are trying to find out "why" people want it included before you decide what to do. However, I would ague that because so many people use it, is really just as valid of a reason. If the goal of this project is to help beginners, then I would suggest most beginners out there probably have spent a lot of time in the world of SASS over the last few years on the web. These newer concepts for CSS are great, but for most people SASS is what they know. So by limiting these people to either new concepts or plain CSS you limit the goal of the project. Just my thoughts. |
Just to make it clear, you can use SASS with this project if you want to. If you’re used to SASS, you’re also probably used to launching it in the console and letting its watcher compile the SASS files. So this is exactly what you can do:
Yes, this is a bit of extra work, but it’s perfectly doable. |
@gaearon there is some important issue with your solution: you can't run the whole your development environment with a single |
How is opening a second terminal window a blocker? 😃 It's |
You can also change your |
There are workarounds to that too. |
@gaearon thank you, that probably solves my issue |
@just-boris you can define |
The I also recommend using Another thing to keep in mind is that the My npm "scripts": {
"dev-server": "node ./scripts/start.js && kill $WATCH_SASS_PID",
"background-sass-watcher": "./node_modules/.bin/node-sass --watch --recursive src -o src & WATCH_SASS_PID=$!",
"compile-sass": "./node_modules/.bin/node-sass --recursive src -o src",
"start": "npm run compile-sass && npm run background-sass-watcher && npm run dev-server",
"build": "npm run compile-sass && node ./scripts/build.js"
}, |
My 2 cents in the discussion. The only thing I will support having by default is |
My workaround uses |
Is there any reason flags can't be supported. For instance |
This is my personal opinion so please don’t take this as an official position of React team or something like that. Here goes. Adding any flag explodes the number of possible configuration we need to support. The day we add
We take issues in the underlying libraries very seriously. We follow up with them and make sure they get fixed, fork or replace the dependencies, if necessary, so that our users have the best experience. But we are not ready to officially support the spectrum of CSS transpilation alternatives. Unlike, for example, Babel plugins, we don’t use SASS or Less at Facebook, so we have no idea which issues are affecting the users, and would not be able to allocate enough time and effort to fix them. Unlike with webpack, we wouldn’t get to constrain the features you use to a tightly controlled subset so that we could ensure they work well together. Additionally SASS (the most commonly requested tool in this thread) is a wrapper over a native binary written in C/C++ which adds more rare but complex issues that we wouldn’t be able to help anyone with. If you never had any issues with these tools, it’s great. It is however not cool if somebody attempts to run a React example built with an official React toolkit, and they get a segmentation fault. At this point in time we are going to keep treating CSS transpilation as a problem outside of CRA concern. As demonstrated above you can use SASS/Less or something else in a CRA pre-ejected app if you treat Also, as I said previously, we intend to look into this space (styling in React) later this year. If our effort is unfruitful, we might give in and enable SASS/Less by default, but this will require Create React App to further mature and prove its value anyway. Let’s revisit this topic in the beginning of 2017. |
We now have official Sass integration documentation. For now I think this is enough, and covers the use cases most people have. |
We're exploring a tighter integration in the spirit of what most people in this thread wanted (just import it and it works). But we'll need some changes on |
Sass is now supported. |
Note from Maintainers
We now have official Sass integration documentation.
Would be nice to include CSS compilers such as: Sass, Less, Stylus, or even CSS modules, etc.
The text was updated successfully, but these errors were encountered: