SCSS/SASS include in Nuxt project

Sass include in Nuxt project.

Simple css styles are no longer enough when it comes to more complex projects.
The linearity of the css is an obstacle compared to more complex structures, such as those provided for the compiled SCSS/SASS styles.

To include custom scss in your project we can install sass-loader.

npm i -D sass-loader@10.1.1 --save-exact && npm i -D sass

The version of sass-loader needs to be exact and set at the latest 10.x.x because the next one (11.0.0) is using Webpack5, hence being a breaking change because Nuxt2 is only running on Webpack4 (

When installed we to add that loader in our nuxt.config.js.

export default {
  // ...
  build: {
    loaders: {
      sass: {
        implementation: require('sass'),
      scss: {
        implementation: require('sass'),
  // ...

And later we can try in the component.

    <span class="my-class">
      Hello my class!

<style lang="scss" scoped>
div {
  .my-class {
    color: green;

Common SCSS resources

For common scss resources (like variables or mixins) you can install:

npm install --save-dev @nuxtjs/style-resources

And then import them into nuxt.config.js, inside the modules configuration.

modules: [
    // ...

And set them, still inside nuxt.config.js.

styleResources: {
    scss: [

That’s all.
Try it at home!

Be the first one to like this.
Please wait...

Leave a Reply

Thanks for choosing to leave a comment.
Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published.
Please do NOT use keywords in the name field. Let's have a personal and meaningful conversation.