I am experiencing issues with the interpolation of my SASS variables when they are placed into

I am relatively new to the Nuxt ecosystem and I must say it's an awesome package that really simplifies our lives.

Currently, I am attempting to incorporate sass into my project. Despite following the steps outlined in the documentation, my build is running smoothly but unfortunately, my scss files are not being compiled. Here is an example of the issue:

https://i.stack.imgur.com/ySEem.png

You can see that --thm-font is set to $primaryTypography instead of the expected value from the .scss.

What I am expecting to see is --thm-font: 'Barlow', sans-serif. It seems like the sass is not being compiled properly. It's worth noting that I am not aiming for a component-based style; rather, I want to have a separate main.scss file where I will import various styles including components and layouts.

_variables.scss

// Base colors
$base: #ee464b;
$baseRgb: (238, 70, 75);
$black: #272839;
$blackRgb: (39, 40, 57);
$grey: #f4f4f8;

// Typography
$primaryTypography: 'Barlow', sans-serif;

@debug $primaryTypography; // -> this one outputs the correct value

:root {
  --thm-font: $primaryTypography;
  --thm-base: $base;
  --thm-base-rgb: $baseRgb;
  --thm-black: $black;
  --thm-black-rgb: $blackRgb;
  --thm-gray: $grey;
}

nuxt.config.js


export default {
  mode: 'universal',
  loading: { color: '#fff' },
  css: [
    '~assets/scss/main.scss'
  ],
  plugins: [
  ],
  buildModules: [
  ],
  modules: [
  ],
  optimizedImages: {
    optimizeImages: true
  },
  build: {
    extend (config, ctx) {
    },
    loaders: {
      sass: {
        prependData: '@import "~@/assets/scss/main.scss";'
      }
    }
  },
  server: {
    port: process.env.APP_PORT
  }
}

package.json

{
  "name": "zimed",
  "version": "1.1.0",
  "description": "Zimed - Vue Nuxt App Landing Page Template",
  "author": "Layerdrops",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate"
  },
  "dependencies": {
    "@bazzite/nuxt-optimized-images": "^0.3.0",
    "nuxt": "^2.0.0",
    "sass-loader": "10"
  },
  "devDependencies": {
    "fibers": "^5.0.0",
    "sass": "^1.38.2"
  }
}

I would appreciate guidance on which configuration setting I might be missing in order to compile the .scss files correctly.

Answer №1

To properly include a variable, use interpolation like so

--thm-font: #{$primaryTypography};
within the :root context.
Although the reason for this behavior is unclear, I discovered it through this particular answer.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilize multiple background images in CSS with a set of three unique images

I have inserted three images into the background of my website's body. Two of them are displaying correctly (one with repeat-y), but the third one is not working. I've tried searching a lot but couldn't find a solution. body { backgr ...

Can you explain the distinction between the fontawesome angular package, the standard npm package, and simple sass?

In my new Angular CLI project (version 8+) that is using Sass (SCSS), I have been exploring the Fontawesome documentation and discovered there are several methods for hosting Fontawesome icons. These include installing the npm package, integrating the angu ...

What is the best method for selecting or deselecting all checkboxes except for one using a single checkbox in angularjs

$scope.checkAll = function() { if ($scope.selectedAll) { $scope.selectedAll = true; } else { $scope.selectedAll = false; } angular.forEach($scope.MyProducts, function(item) { item.Selected = $scope.selectedAll; }); /*});*/ } <di ...

Encountering a Babel error while attempting to compile my front-end assets using Laravel Mix. The module build process fails, causing

I've been struggling to fix this persistent error, trying various solutions from different sources including Git, but nothing seems to work. Error: Module build failed: this.setDynamic is not a function In my package.json file, I have the following ...

Automatically change div background image based on window resizing

.step-1-4 { background:url('../images/gadget-4-sprite.png') no-repeat; width:950px; height:70px; margin-left: 15px; } The code above sets the CSS for a div containing a background image. The dimensions of the div match that of the imag ...

Ensure that the dropdown <select> remains open even while filtering through options

I am currently working on implementing a mobile-friendly "filtered dropdown" design: Usually, a <select> control remains closed until the user clicks to open it. Is there a straightforward way to keep it always open? I understand that this would ma ...

Positioning multiple images in CSS

I am facing an issue with my background images where one of them is invisible and cannot be displayed. Additionally, the padding-top for the li a element seems to not be working properly. HTML: <ul class="menu"> <li class="item-101 current a ...

Tips for controlling the placement of divs on a webpage

I need to align 3 divs in a specific way on my webpage. One should be on the left side taking up 25% of the window, one on the right side also taking up 25%, and the last one in the center taking up the remaining space. I'm struggling with how to achi ...

The fields in the row of the Rails form_tag are overly spacious

My login form in Rails 4 with Bootstrap 3 is giving me trouble. It doesn't format well on any device, especially smaller screens where it becomes unusable. I suspect the huge right margin of the rows is to blame, but I can't figure out the root c ...

Challenge with aligning tables

I need assistance with aligning the TD tag value to the TH tag value as I am currently experiencing alignment issues. Can someone please help me resolve this problem? I have attempted to fix it on jsfiddle Here is the HTML code: <table class=" ...

leveraging vue script setup via content delivery network

Is it possible to write a Composition API script setup using a CDN like this? <template> {{message}} </template> <script setup> message:"welcome"; </script> I have searched for a solution but found none. I have used ...

Responsive Video Embed Using Bootstrap-5

I'm facing some challenges with Bootstrap responsive video embedding. It seems like the parent container is not responding to changes, only the content within the <iframe> tag is being responsive. Any idea what might be going wrong? .embed- ...

Set a placeholder to display when Vuex has completed loading

How can I properly handle loading state after dispatching in Vue? Currently, when trying to set loading state to true before dispatch and false after, the following code does not work: this.loading = true; this.$store.dispatch('items', data); t ...

The call stack limit has been exceeded in VueJS/VueX

I'm currently developing a Vue project with Vuex for state management. However, I encountered a Maximum call stack size exceeded error in my console when attempting to bind actions and getters in my component using mapActions and mapGetters. I'm ...

Tips for enabling a flexbox item to extend beyond its container

While attempting to utilize flexbox for creating a navbar with the logo in the center, I encountered an issue where the logo wasn't able to overflow from above and below the navbar. I experimented with squeezing in and positioning the element, but it ...

"Exploring the screen size options in Chrome version 38 using the

After the recent update, Chrome has introduced several new features for web developers. However, I've noticed that when you drag the screen with the developer tools open, it used to display the exact screen width size in the top right corner. Now, it ...

Hover background color not being applied to child elements within Button element in Firefox

Ensuring that my product is SEO-friendly, I incorporated semantic markup using the button element and schema attributes. To separate individual items, I utilized "span" elements while setting hover effects on selected items by adding display:block. This a ...

Using Angular 2 to position a md-fab button with 'position: fixed' inside an inner component

Utilizing the md-fab-button from the initial angular2 material-framework has presented a challenge for me. I am attempting to set the md-fab-button(for adding a new entity) with position: fixed, but my goal is to position the button within an inner compone ...

What are the steps to achieve such a design?

Can you show me how to create a single layout using HTML and CSS? I am struggling with splitting the screen properly. Could you provide a simple example, maybe on jsfiddle? https://i.stack.imgur.com/d2rbn.jpg Thank you in advance! EDIT: I have added a ...

Show an item from a list in Vue.js depending on the current time

When retrieving a list of objects (trips) from an API, I need to determine if any trip object meets the following criteria: A trip object includes -> startTime, estimatedTime, begin, destination Criteria: If there is a trip where startTime + estimated ...