Unable to access Vuetify Sass module configuration

See original GitHub issue

(as discussed Kael on Discord)

https://github.com/glen-84/vuetify-loader-issue

If you try to forward the configured Vuetify Sass module with something like:

main.scss

@forward "vuetify/styles" with
    (
        $body-font-family: "monospace"
    );

app.vue

<style lang="scss" scoped>
@use "./main" as x;

a {
    font-family: x.$body-font-family;
}
</style>

You see two different types of errors:

  1. modulesTypeError: options.awaitResolve is not a function
  2. SassError: This variable was not declared with !default in the @used module.

image


@KaelWD What is the best way forward here? (excuse the pun)

If this is not possible, should developers manually import the Sass files?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:27 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
KaelWDcommented, Aug 31, 2022

This is now officially supported and I’ve updated the documentation: https://next.vuetifyjs.com/en/features/sass-variables/

3reactions
KaelWDcommented, Aug 25, 2022

This seems to work for me:

// main.scss
@use './settings';
@use 'vuetify/styles';
// _settings.scss
@forward 'vuetify/lib/styles/settings' with (
  $color-pack: false,
  $container-max-widths: (
    xs: null,
    sm: null,
    md: 768px,
    lg: 1250px,
    xl: 1800px,
    xxl: 2300px,
  ),
);

@forward 'vuetify/dist/component-variables' with (
  $button-height: 56px,
);
// App.vue
<style lang="scss">
  @use './settings';
  
  @debug settings.$button-height;
</style>

Or if having it split between general and component variables is too confusing:

// _vuetify.scss
@forward 'vuetify/lib/styles/settings';
@forward 'vuetify/dist/component-variables';
// _settings.scss
@forward './vuetify' with (
  $color-pack: false,
  $container-max-widths: (
    xs: null,
    sm: null,
    md: 768px,
    lg: 1250px,
    xl: 1800px,
    xxl: 2300px,
  ),
  $button-height: 56px,
);

If you use pnpm or yarn plug-n-play though you might have to switch to something else, there must be a bug in sass or something because the symlinked files don’t have the variables defined.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SASS variables
The Nuxt Vuetify module exposes a vuetify property where you can configure the module. Ensure that you enable the treeShake option first. This ......
Read more >
Unable to override Vuetify 2.1 SASS variables
Set all top-level variables before importing Vuetify, so that Vuetify doesn't overwrite. set these variables before Vuetify does
Read more >
Working with CSS
Vue CLI projects come with support for PostCSS, CSS Modules and pre-processors including Sass, Less and Stylus.
Read more >
How to Import a Sass File into Every Vue Component in an ...
Now, let's create a file called vue.config.js at the root of the ... module.exports = { css: { loaderOptions: { sass: { data:...
Read more >
Use CSS in Gridsome
You can also use SASS in Vue Components with the lang="scss" attribute: ... to the top of your gridsome.config.js file before the existing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found