vuetify-nuxt-module: Unable to Use Vuetify Sass Variables
Hi.
Thank you for this excellent library. It surpasses the official vite-plugin-vuetify plugin by miles.
However, I’ve encountered an issue. I’m not sure if it’s a bug or if something in my configuration is incorrect. I hope someone can help me.
I want to use some of Vuetify’s SASS variables (such as $display-breakpoints) in my project, but I’m facing difficulties.
This is my nuxt.config.ts file:
import {defineNuxtConfig} from 'nuxt/config'
export default defineNuxtConfig({
ssr: true,
css: [
'@/assets/styles/main.scss'
],
experimental: {
inlineSSRStyles: false
},
modules: [
'vuetify-nuxt-module'
],
vuetify: {
moduleOptions: {
styles: {
configFile: 'assets/styles/vuetify.scss' // <--------- NOTICE
}
},
vuetifyOptions: './vuetify.config.ts'
},
vite: {
css: {
preprocessorOptions: {
scss: {
additionalData: `
@use "@/assets/styles/variables/_colors.scss" as *;
@use "@/assets/styles/variables/_variables.scss" as *;
@use "vuetify/lib/styles/settings/variables" as *; // <--------- NOTICE
`
}
}
}
}
})
And this is assets/styles/vuetify.scss:
$font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
"Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
"Noto Color Emoji";
$size-scales: (
'x-small': -1.75,
'small': -1,
'default': 0,
'large': 1,
'x-large': 2
);
@use "vuetify/settings" with (
$color-pack: false,
$body-font-family: $font-family,
$font-size-root: 18px,
);
But I encountered this error:
500
[vite-node] [plugin:vite:css] [VITE_ERROR] ./node_modules/vuetify/lib/styles/settings/_index.sass:1:1
Error: This module was already loaded, so it can't be configured using "with".
┌──> node_modules/vuetify/lib/styles/settings/_index.sass
1 │ @forward './variables'
│ ^^^^^^^^^^^^^^^^^^^^^^ new load
╵
┌──> assets/styles/vuetify.scss
4 │ @use "vuetify/lib/styles/settings/variables" as *;
│ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ original load
... │
205 │ ┌ @use "vuetify/settings" with (
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Comments: 19 (6 by maintainers)
I don’t think there’s a need to create a new issue. The problem has been solved. I was using nuxt-i18n, which was the main reason for not loading UI with RTL styles. After checking the playground and configuring i18n properly, the issue is resolved.
Thank you to you and @TechAkayy for your helps. I really appreciate it 🔥
Hey mate,
I’m not a sass expert either, my efforts have been purely trial & error. This is the best I could do - https://stackblitz.com/edit/nuxt-starter-sndsr7?file=nuxt.config.ts.
Refer to these files I have updated and compare with yours:
The below variables.scss is a new addition when compared to https://github.com/Pinegrow/pg-nuxt-vuetify. Again, this is based on my assumption that when imported via app.vue, it overrides the css/scss imports of nuxt config. Not sure if it really works. If you are an sass expert, you might probably know better than me 😃
You can find comment with my initial
AK:in variables.scss. All the best!If you look closely into https://github.com/Pinegrow/pg-nuxt-vuetify, you will notice the there are two sass files & they are configured differently to how you have in your nuxt.config.ts. Also take a note of
@forward 'vuetify/settings' ..and@use 'vuetify'..and compare with yours.Hi @mostafaznv, do you have a sample repo I can have a look? I think I encountered this in the past.