Having issues compiling SCSS syntax in a Vue3 app on Vite

I am having difficulties using the scss nesting syntax.

_table.scss

table {   &.table {     width: 100%;   } }
See results in dev tools

I included my _table.scss file into main.scss and then imported main.scss into main.js main.scss main.js

This is a list of package.json dependencies

{
  "name": "morphzing-vue3",
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview",
    "lint": "eslint --ext .js,.vue src --ignore-path .gitignore .",
    "lintfix": "eslint --ext .js,.vue src --ignore-path .gitignore . --fix"
  },
  "dependencies": {
    "@kyvg/vue3-notification": "^2.7.0",
    "@vuelidate/core": "^2.0.0",
    "@vuelidate/validators": "^2.0.0",
    "pinia": "^2.0.23",
    "vue": "^3.2.45",
    "vue-router": "^4.1.5",
    "vuetify": "^3.0.1"
  },
  "devDependencies": {
    "@mdi/js": "^7.0.96",
    "@rushstack/eslint-patch": "^1.1.4",
    "@vitejs/plugin-vue": "^3.1.2",
    "@vue/eslint-config-prettier": "^7.0.0",
    "eslint": "^8.22.0",
    "eslint-plugin-vue": "^9.3.0",
    "prettier": "^2.7.1",
    "sass": "^1.56.1",
    "vite": "^3.1.8"
  }
}

Here is my vite.config.js file

    import { fileURLToPath, URL } from 'node:url'
    
    import { defineConfig } from 'vite'
    import vue from '@vitejs/plugin-vue'
    
    // https://vitejs.dev/config/
    export default defineConfig({
      plugins: [vue()],
      server: {
        port: 8080,
        hot: true
      },
      resolve: {
        alias: {
          '@': fileURLToPath(new URL('./src', import.meta.url))
        }
      },
      css: {
        preprocessorOptions: {
          scss: {
            additionalData: `
              @import "./src/assets/variables.scss";
              @import "./src/assets/theme/colors.scss";
            `
          }
        }
      }
    })

I followed the vite API reference

When I use simple syntax like .block .block__item or scss syntax in vue components, it works perfectly:

Simple syntax used in my _table.scss file

    table td {
      vertical-align: middle;
      
    }

scss syntax used in vue components

    <style lang="scss" module>
        .block:global(.v-navigation-drawer--is-hovering) {
          .block__logo {
            padding: 24px;
          }
          .block__nav--nested {
            padding: 0;
            padding-left: 12px;
          }
        }
        .block:not(:global(.v-navigation-drawer--is-hovering)) {
          .block__nav {
            padding: 0;
        
          }
        }
    </style>

I also attempted to use sass-loader but unfortunately, it did not work in my case :(

Answer №1

My coworkers came up with a resolution. We needed to eliminate the import through URL in main.scss

This is how my code looks now in main.scss

@import './parts/_table.scss';

@import './typography.scss';
@import './helpers.scss';

@import './variables.scss';
@import './theme/colors.scss';

The nesting syntax from SCSS is now functioning

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

What is the process for setting up redux in _app.tsx?

Each time I compile my application, I encounter the following error message: /!\ You are using legacy implementation. Please update your code: use createWrapper() and wrapper.useWrappedStore(). Although my application functions correctly, I am unsure ...

Enable contenteditable on table by pressing the tab key

I developed a table entry tool and I would like to be able to input items by pressing the tab key instead of having to manually click on each element. I haven't been able to figure out how to make this function work yet. $('table').on(&apos ...

showing information retrieved using the fetch function

Currently, I am attempting to retrieve the user's input value from a search box and then proceed to use this variable in my endpoint to retrieve data. <input type="text" class="search" placeholder="planet"> <script> const media = &apo ...

Instructions on how to successfully send an AJAX request without having to open the webpage while utilizing Google App Engine

When sending AJAX requests without having to open a webpage on Google App Engine, you can utilize JavaScript libraries like jQuery $.ajax or $.post. However, if you want to send an AJAX request and receive the return value without opening a webpage, espec ...

Utilizing an npm Package in Laravel - Dealing with ReferenceError

I'm having trouble with the installation and usage of a JS package through npm. The package can be found at . First, I executed the npm command: npm install --save zenorocha/clipboardjs Next, I added the following line to my app.js file: require(& ...

What is the best way to link and store invoice formset with the main form foreign key in Django?

I am new to Django and need help. I am trying to save my invoice in a database, but the issue I'm facing is that I can't retrieve the foreign key from the main form when I try to save the formset. View.py def createInvoice(request):` if requ ...

Utilizing an AngularJS custom filter twice

Experimenting with a custom Angular filter example found at: https://scotch.io/tutorials/building-custom-angularjs-filters#filters-that-actually-filter, my version looks like this: <!DOCTYPE html> <html> <script src="http://ajax.googleapi ...

The deprecated warning in the console for Vue 3 Google Sign-In User Authentication indicates a potential issue with

Incorporating the Sign in using Google functionality into my Vue 3 application has been a challenge. While I came across some npm packages that could help, they are unfortunately soon to become deprecated (This warning is displayed in the console). I am i ...

Identifying and retrieving elements in JavaScript

I'm trying to extract the unique selector path of an HTML element using a script I found at this source. The generated path appears as follows: html>body>section:eq(3)>ul>li:eq(1)>div Can someone guide me on how to use JavaScript or j ...

A step-by-step guide on combining multiple STL files into a single geometry

Is there a simpler way to handle this code for exporting to an STL file or for the cutting function? I find the current method too troublesome. Thank you! var material1 = new THREE.MeshPhongMaterial( { color:0xffffff, } ); loader.load( 'fanban1.s ...

Generating arrays and datasets using the power of JavaScript and jQuery

Recently, I wrote a code to arrange points inside a table, and everything was working perfectly when I specified an arrayOfDivs: http://jsfiddle.net/u58k6/6 var arrayOfDivs = [({topPosition : 99, leftPosition: 100}),({topPosition : 150, leftPosition: 400} ...

Exploring the possibilities of wildcards in npm scripts on Windows

Currently, I am attempting to use jshint to lint all of my javascript files by utilizing an npm script command. Even though I am working on a Windows system, I am facing an issue where I cannot successfully lint more than one file regardless of the wildca ...

Getting a callback from an event listener in Nuxt/Vue: A step-by-step guide

I am currently using Nuxt version 2.15.8 and I am looking for a way to retrieve the result of an emitted event. In my setup, there is a child component that emits the event, then the parent component receives it and makes API calls based on it. I want to e ...

Communicating with Socket.io using the emit function in a separate Node.js module

I've been trying to make this work for the past day, but I could really use some assistance as I haven't had much luck figuring it out on my own. App Objective: My application is designed to take a user's username and password, initiate a m ...

using JavaScript to strip away content following .jpg

var lochash = "#http://www.thepresidiumschool.com/news_image/102%20NRD_7420.jpg&lg=1&slide=0"; I am looking to eliminate or modify the content that comes after .jpg. ...

Modifying the property value in a child component using the parent component in VueJS

Hey there, I'm facing an issue where I need to update a prop in my child component when the parent component changes the value. However, I'm attempting to do this in a unique way and running into a problem where the child prop is not being update ...

Applying inline css transition style using a string distorts the original value. Strange

I have a CSS file that specifies a transition property as follows (vendor prefixes excluded for brevity): transition: opacity 1s; Now, I want to tweak the transition-delay property of each element using JavaScript to create a stagger effect. Here's h ...

Interactive page driven by AJAX/jQuery

I am currently working on developing a user-friendly map that showcases various business locations within my vicinity. The main page, map.php, features the interactive map while I have also set up another page, business.php, which provides in-depth informa ...

What is the best way to search for a specific string within an Airtable record that may also have additional data included?

By utilizing the filterByFormula method in the airtable api, I am able to query and choose records that include a specific item (string). However, this query will only return the records that exclusively have that particular string. Referencing the airtab ...

Step-by-step guide on importing popper.js

While it may seem like a simple question, I am struggling to find the answer. How can I import popper.js that comes with Bootstrap 4 beta? I am using Bower and have successfully installed Bootstrap 4 beta. However, in the bower_components folder, there is ...