Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run SASS with React on Vite?

Tags:

sass

reactjs

vite

I created a React project with Vite and want to use SASS as well. I have it installed already but I usually open a git bash and run sass -w sass:css.

Is there a better way to do it? I couldn't understand a solution in the docs, nor an answer online.

This is my package.json:

{
  "name": "my_first_vite",
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview"
  },
  "dependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  },
  "devDependencies": {
    "@vitejs/plugin-react": "^1.0.7",
    "sass": "^1.49.0",
    "vite": "^2.7.2"
  }
}
like image 325
8koi Avatar asked Sep 12 '25 16:09

8koi


1 Answers

I found the answer in the vite docs. I had to run:

npm add -D sass
like image 193
Kelvin Mutuota Avatar answered Sep 14 '25 08:09

Kelvin Mutuota