Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vite how to use sass

enter image description here

Vue.config.js

enter image description here

when i install sass and sass-loader how can i to configure to use sass Now i use sass tips error Cannot find module 'sass' from 'D:\demo\vite' enter image description here

like image 413
can i use Avatar asked Jan 06 '21 02:01

can i use


People also ask

Does Vite support sass?

Vite improves @import resolving for Sass and Less so that Vite aliases are also respected. In addition, relative url() references inside imported Sass/Less files that are in different directories from the root file are also automatically rebased to ensure correctness.

How do you use SCSS in VUE 3?

Install vue 3 (You can probably skip this step if you have Vue already set up!) If you have the Vue CLI tool, just run vue create scss and select Vue 3. There is an option to set up CSS pre processors from the CLI tool but for this article I will ignore that option. Once set up, cd scss to move into that directory.

How do I use TypeScript with Vite?

Using Vite to create the TypeScript React application. Before you start, you should have recent versions of Node and npm installed on your system. The first step is to use the Vite command to create a new application. This can be done using the npm init command without installing any additional software.


Video Answer


4 Answers

You just need to install sass using the following command

npm install -D sass

Also, you may check the official docs here https://vitejs.dev/guide/features.html#css-modules

like image 136
Md. Helal Uddin Avatar answered Oct 26 '22 22:10

Md. Helal Uddin


Try

yarn add -D sass

it's pretty much the error given in the last screen.


Since people prefer to use NPM apparently but that there is a lot of package managers nowadays, here we do have an universal solution

By using ni, you can have

ni -D sass

to install that in your project whatever it's using NPM, yarn, PNPM or bun.

like image 29
kissu Avatar answered Oct 26 '22 22:10

kissu


In other answers, they're using yarn or npm but If you're using pnpm:

pnpm i -D sass

i is an alias for install:

https://pnpm.io/cli/install

-d flag:

https://pnpm.io/cli/install#--dev--d

like image 2
amiria703 Avatar answered Oct 26 '22 21:10

amiria703


btw if you aready did npm i sass you can perfectly do npm i -D sass the changes will be made automagically!

like image 1
8koi Avatar answered Oct 26 '22 21:10

8koi