Home > Net >  How do I get my react js app to start watching my sass files?
How do I get my react js app to start watching my sass files?

Time:12-09

How do I get my react js app to start watching my sass files? I did npm i sass vs npm i node-sass because I learned that node-sass is depreciated, I'm not sure if that has anything to do with automatic sass watching? (also, I have the latest version of node installed)

I know when you're not using a framework you have to type into the terminal " sass --watch input.scss output.css.", do I have to do the same in react js? Also in my components I have imported the main.scss sheet!

this is the error I get when I try to run my react js app:

Failed to compile ./src/components/Login.js Module not found: Can't resolve './scss/main.scss' in '/Users/karinapichardo/Desktop/login-project/src/components'

what am I missing to do? any help would be greatly appreciated

CodePudding user response:

You are trying to import the SCSS file from the directory where Login.js is.

You should modify your import path to be like this:

import "../scss/main.scss"; // 2 dots at start of path

instead of like this:

import "./scss/main.scss";

Which will essentially navigate to the src directory before accessing the rest of the path

  • Related