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.

Add SASS documentation

See original GitHub issue

Adding SASS (or Less) support in a project bootstrapped using create-react-app, doesn’t require any advanced modifications. It’s seems more intimidating than it actually is. We don’t even have to eject.

First, install preprocessor of your choice. SASS seems the most popular weapon of choice at the moment, so we’ll use it as an example:

npm install node-sass --save-dev

Then in package.json just add the following lines:

"scripts": {
   ...
   "build-css": "node-sass src/sass/base.scss src/index.css",
   "watch-css": "node-sass src/sass/base.scss src/index.css -w",
   ...
}

and run them alongside main scripts, by adding npm run watch-css & to start script and npm run build-css && to build.

  "scripts": {
    "start": "npm run watch-css & react-scripts start",
    "build": "npm run build-css && react-scripts build",
    "build-css": "node-sass src/sass/base.scss src/index.css",
    "watch-css": "node-sass src/sass/base.scss src/index.css -w",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }

As far as I’m concerned, that works using Less as well.

Is that something that would belong in current documentation?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:41
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
themrecommented, Dec 6, 2016

Any news on this? I found a way to store all scss files in some folder and export them in other:

"build-css": "node-sass src/style/sass/ -o src/style/css/",
 "watch-css": "node-sass -w src/style/sass/ -o src/style/css/",

-w is used for watch, -o is used for output. This will export individual files (scss -> css) into corresponding directory. Would be nice to include this somehow into webpack CSS bundle.

0reactions
sudip1072commented, Dec 9, 2018

Such problem came when you change your node version.Use following command and serve the application on browser. npm rebuild node-sass --force

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Sass
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
Once Sass is installed, you can compile your Sass to CSS using the sass command. You'll need to tell Sass which file to...
Read more >
Sass: @use
Syntactically Awesome Style Sheets.
Read more >
Install Sass
You can install Sass on Windows, Mac, or Linux by downloading the package for your operating system from GitHub and adding it to...
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 >

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