Vite how to use sass
Asked Answered
A

5

37

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

Anny answered 6/1, 2021 at 2:13 Comment(1)
Please provide the code snippets as code not images...Mclane
F
72

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

Foment answered 7/3, 2021 at 11:7 Comment(0)
S
8

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.

Sinistrality answered 6/1, 2021 at 2:33 Comment(2)
thanks when i create a new project and i install sass is ok But the old project can't I think may be i can't handle goodAnny
Why couldn't the old one handle Sass? Got an error?Sinistrality
C
3

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

Cottingham answered 5/4, 2022 at 5:7 Comment(0)
O
2

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

Onaonager answered 20/6, 2022 at 13:16 Comment(0)
R
2
 npm add -D sass

Then you can use in your .vue file. <style lang="scss"></style>

You can find it in vite official website.Vite scss

Reiner answered 23/2, 2023 at 8:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.