question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Optional Sass support - Part 2

See original GitHub issue

As I just read in https://github.com/facebookincubator/create-react-app/issues/78, CRA don’t want to add support to Sass and Less.

Then, I read Dan saying:

Let’s revisit this topic in the beginning of 2017.

So, what’s the state of this? I few hours ago I implemented Sass and Less in a personal project out of CRA. I just added a new rule in webpack modules, and a couple of dependencies and Gualá! Following this example, we should do not deal too much with this implementation: https://github.com/webpack-contrib/sass-loader#examples

Something really nice in those loaders is that it’s not necessary to convert Sass to CSS explicitly. So, ~as all loaders do~, just including the .scss file is enough.

I read tons of times that you repeat the same question: “Why you guess Sass is necessary in React?”. Well, in my case, I don’t use Sass to reutilize CSS. I use Sass to write CSS as a tree, and it’s useful to define vars that are useful to create a template structure in the site/component.

My best example (tree view, vars, cals, and imports that can be used to define the whole site styling):

@import './base/colors.scss';

.Xxxxx {
  $width: 30px;

  position: fixed;
  right: 10px;
  bottom: 10px;
  width: $width;
  height: $width;
  border: 1px solid $color-primary;
  border-radius: 5px;
  cursor: pointer;

  > i.anticon-smile-o {
    color: $color-primary;
    font-size: calc(#{$width} * 0.60);
    line-height: $width;
  }
}

If you think it’s time to add Sass, I can create a PR with those chances (or, at least, I’ll try). If not, ok.

Thank you!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:35
  • Comments:29 (14 by maintainers)

github_iconTop GitHub Comments

70reactions
Fangmingducommented, Jul 1, 2017

why don’t you add an option for adding sass/less to the project when create a new project like: create-react-app my-app --style=sass otherwise, the default should still be css and not including any additional sass loaders.

This was used similarly in angular-cli project, link here

28reactions
BrodaNoelcommented, Jun 8, 2017

Nop. That’s support for pre-processors (from Sass to Css), and then You have to include the CSS file, instead of the .scss.

I’m asking if we can add the Sass loader to our Webpack config, so then will not be necessary to do those changes in package.json, or install new dependencies (as you can read in that doc you shared)

El 8 jun 2017, a las 02:45, Cristian Rosescu notifications@github.com escribió:

CRA has been providing SASS support for a while now

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

mixin and @include
This is especially useful for mixins with multiple optional arguments, or with boolean arguments whose meanings aren't obvious without a name to go...
Read more >
Sass: @import
Sass extends CSS's @import rule with the ability to import Sass and CSS stylesheets, providing access to mixins, functions, and variables and combining ......
Read more >
Sass: Documentation
Sass is a stylesheet language that's compiled to CSS. It allows you to use variables, nested rules, mixins, functions, and more, all with...
Read more >
Sass Basics
This is where a preprocessor can help. ... For example, running sass input.scss output.css from your terminal would take a single ... Sass...
Read more >
Sass: @extend
Extension Scope; Mandatory and Optional Extends; Extends or Mixins? ... that matches the intersection of two selectors, while the selector.extend() function ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found