I am trying to import a global Sass stylesheet from the /assets directory and use stuff like variables and mixins defined there throughout the components. My nuxt.config.ts looks like this currently:
import { defineNuxtConfig } from "nuxt3";
export default defineNuxtConfig({
css: ["@/assets/styles/main.sass"],
styleResources: {
sass: ["@/assets/styles/main.sass"],
},
build: {
extractCSS: true,
styleResources: {
sass: "@/assets/styles/main.sass",
hoistUseStatements: true,
},
},
// buildModules: ["@nuxtjs/style-resources"], // This throws error
vite: {
css: {
loaderOptions: {
sass: {
additionalData: ` @import "@/assets/styles/main.sass"; `,
},
},
},
},
});
When I try to use a variable now, I get [plugin:vite:css] Undefined variable. error. This used to work very well in Nuxt 2 with @nuxtjs/style-resources but I'm not sure how to make this work in Nuxt 3.
However, classes and applied styles from that stylesheet are working, only varibles, mixins and maps are not accessible.
Can someone please help?