I am using sass with vue version-3. In one of my components I have this code:
HelloWorld.vue :
<template>
<div class="greetings">
<h1>{{ msg }}</h1>
<h3>
You’ve successfully created a project with
<a href="https://vitejs.dev/" target="_blank" rel="noopener">Vite</a> +
<a href="https://vuejs.org/" target="_blank" rel="noopener">Vue 3</a>.
</h3>
</div>
</template>
<script setup>
defineProps({
msg: {
type: String,
required: true
}
})
</script>
<style scoped lang="scss">
@use "sass:list";
@use "@/assets/sass-folder/variables";
@use "@/assets/sass-folder/main";
h1 {
color: list.nth(variables.$theme-lighten-1, 2);
}
h3 {
color: var(--blue);
}
</style>
In that component I inserted a main.scss file with the help of @use
sass command. But the css variable --blue
is not recognized by this component. This is the code of main.scss
file:
main.scss :
:root {
--blue: #1e90ff;
--white: #ffffff;
}
//h3 {
// color: red;
//}
If I un-comment the h3 styles in that file, the color of h3 tag in my component becomes red, so the file is imported correctly. Could anyone please help me which part of my codes is wrong that --blue
variable is not recognized in HelloWorld.vue
component?