-
-
Save ricardoaguiar/95f8fb9d07a5d498ac40e321fd60c572 to your computer and use it in GitHub Desktop.
Injecting global SCSS variables in Astro (https://astro.build), using additionalData and a path alias
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { fileURLToPath } from 'url'; | |
import path, { dirname } from 'path'; | |
const __filename = fileURLToPath(import.meta.url); | |
const __dirname = dirname(__filename); | |
export default { | |
// all the usual config goes here... | |
vite: { | |
resolve: { | |
alias: { | |
'@/': `${path.resolve(__dirname, 'src')}/` | |
} | |
}, | |
css: { | |
preprocessorOptions: { | |
scss: { | |
// path to your scss variables | |
additionalData: `@import "@/styles/vars.scss";` | |
} | |
} | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment