You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.
The documentation gives an example of overriding variables for one component:
some-component.svelte
<style lang="scss">
/* because the directory of `theme.scss` is in `includePaths` */
@use 'theme.scss';
div {
color: theme.$main;
}
</style>
If I'm overriding a variable that is used throughout the app, such as $button-radius, and I don't want to add @use 'theme.scss'; to every component that uses buttons, would I be able to implement a global theme.scss overrides by doing something like this?
svelte.config.js
const path = require('path');
module.exports = {
preprocess: [
sveltePreprocess({
scss: {
importer: makeAttractionsImporter({
// specify the path to your theme file, relative to this file
themeFile: path.join(__dirname, 'static/css/theme.scss'),
}),
// not mandatory but nice to have for concise imports
includePaths: [path.join(__dirname, './static/css')],
prependData: `@import 'theme.scss';`,
},
}),
],
};
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The documentation gives an example of overriding variables for one component:
some-component.svelte
If I'm overriding a variable that is used throughout the app, such as
$button-radius
, and I don't want to add@use 'theme.scss';
to every component that uses buttons, would I be able to implement a global theme.scss overrides by doing something like this?svelte.config.js
(Source: https://stackoverflow.com/a/70166260/452587)
Or is there a better way?
Beta Was this translation helpful? Give feedback.
All reactions