Search code examples
csssassnuxt3.js

Nuxt 3 with sass


How can we use NUXT3 with sass, also please share the documentation.

I tried to add sass into nuxt3 project, but the vite looks like no options to load scss


Solution

  • Install it first and save as devDependency

    $ yarn add sass
    # or
    $ npm install sass --save-dev
    

    Configure if you want to use global scss

    // nuxt.config.ts
    export default defineNuxtConfig({
      // more  
      css: [
        // SCSS file in the project
        "~/assets/style/main.scss", // you should add main.scss somewhere in your app
      ],
    })
    

    In your components

    <style lang="scss" scoped>
     //...
    <style/>