Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Injecting global SCSS variables in Astro (https://astro.build), using additionalData and a path alias
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