How to use Sass in Nuxt 3

Nuxt guide logo

Nuxt 3 and Sass.

Installing Sass as dependency

Install Sass dependency in the Nuxt project, either using Yarn or NPM :

yarn add sass or npm i sass

Creating folder and file

Create a folder called scss inside the assets folder. Also while we here create a scss file and name it as main.scss:

Scss folder inside Assets folder
Scss folder inside Assets folder

Setup Sass in Nuxt config file

In nuxt.config.ts under css configuration, define the entry of the sass file which is the main.scss:

                                
                                        // nuxt.config.ts
// the style will be applied globally
export default defineNuxtConfig({
  css: ['@/assets/scss/main.scss']
});
                                    
                            
Previous post How to detect click outside in Nuxt
Next post How to style child component from parent in Nuxt