@dalton_moen
To run SASS with React on Vite, you can follow these steps:
- Install sass in your project by running the following command in your terminal:
- Install the necessary Vite plugins for handling SASS by running the following command:
1
|
npm install -D @vitejs/plugin-react-refresh @vitejs/plugin-sass
|
- Create a vite.config.js file in the root of your project with the following configuration:
1
2
3
4
5
6
7
8
9
10
|
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import sass from '@vitejs/plugin-sass'
export default defineConfig({
plugins: [
react(),
sass()
]
})
|
- You can now import SASS files into your React components by using the following syntax:
- Start your Vite development server by running the following command in your terminal:
Now, you should be able to use SASS in your React components with Vite.