Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

Vuetify build fails on a Sass variable that is not configurable

ErrorError: This variable was not declared with !default in the @used module.

Short answer

Sass lets you change a module's variables through @use ... with only when that module declares each one with !default. A name that does not exist, or one the module sets without !default, stops the build. Configure Vuetify through the plugin's styles.configFile and override only variables Vuetify exposes.

  • Applies to Vuetify 3, vite-plugin-vuetify, Vite 7, Sass (Dart Sass) 1.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    The error points at one line in your own settings file. Read the variable name on that line and compare it with how it is set up: is it inside the configFile, and does Vuetify define it?

    grep -rn "vuetify/settings\|configFile" src vite.config.*
  2. 2Match what you see, then jump to its fix

    1. 1The error names a variable from your @use 'vuetify/settings' with ( ... ) blockThe variable you override is not declared with !default by VuetifyFix
    2. 2Overrides are in a separate file that is also imported by hand from components or stylesThe settings file is not wired through the plugin's configFileFix

What does the error look like?

  • Error: This variable was not declared with !default in the @used module.
  • @use 'vuetify/settings' with (

Cause 1 of 2

The variable you override is not declared with !default by Vuetify

1Check

Sass's rules for @use ... with say the variable must exist in the module and must carry the !default flag. A typo, a variable from another Vuetify version, or a value Vuetify sets without !default all fail the same way.

grep -n "with (" -A8 src/styles/settings.scss

2Fix

Remove the entry, or rename it to a variable Vuetify lists as configurable in its SASS variables guide. Keep the block as the guide shows it.

// src/styles/settings.scss
@use 'vuetify/settings' with (
  $body-font-family: ('Inter', sans-serif),
);

3Verify

Restart the dev server and run a production build.

npm run build

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 2 of 2

The settings file is not wired through the plugin's configFile

1Check

Sass allows configuring a module only once, the first time it loads. If Vuetify's styles load before your settings, a later 'with' cannot configure it.

grep -n "vuetify(" -A6 vite.config.*

2Fix

Point the plugin at the settings file so it is loaded before each Vuetify stylesheet, and stop importing Vuetify settings elsewhere. In Sass files use 'vuetify/settings', not 'vuetify/styles', which resolves to precompiled CSS.

// vite.config.js
vuetify({
  styles: { configFile: 'src/styles/settings.scss' },
})

3Verify

Start the dev server and check the page uses your override.

npm run dev

Confirmed by raw.githubusercontent.com

Did this fix it?

How do I stop it coming back?

  • Change Vuetify variables only in the one configFile and nowhere else.
  • After a Vuetify upgrade, check each overridden variable name against the SASS variables guide for that version.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Web apps

tsconfig rejects allowImportingTsExtensions

An error that allowImportingTsExtensions needs noEmit or emitDeclarationOnly

allowImportingTsExtensions lets files import each other with .ts or .tsx extensions, and TypeScript only allows it together with noEmit or emitDeclarationOnly.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.