Skip to content

[Bug report] User variables in .vuepress/styles/palette.scss are ignored #571

@dennisreimann

Description

@dennisreimann

In VuePress 2 the default theme forwards the user palette via

@forward '@vuepress/plugin-palette/palette';

and then defines its own variables with !default.

However, in the Sass module system variables defined inside a forwarded module are not visible in the parent scope.
As a result, !default declarations in the theme always apply, even if the user has defined the same variable names.

Expected behaviour:

Variables defined by the user in .vuepress/styles/palette.scss should override theme defaults when the same variable names are used, consistent with the documentation and with VuePress 1 behaviour.

Actual behaviour:

Theme !default values override user-defined variables because the forwarded palette is in a separate module scope.

Minimal reproduction:

// .vuepress/styles/palette.scss
$MQMobile: 999px;

// in theme (simplified)
@forward '@vuepress/plugin-palette/palette';
$MQMobile: 719px !default;

The compiled CSS still uses 719 px.

Possible solution:

Use @use '@vuepress/plugin-palette/palette' with (...) or import variables into the same scope instead of forwarding, so that user values exist before the !default declarations.

Reproduction

See description

Used Package Manager

npm

System Info

Binaries:
    Node: 22.2.0 - /home/d11n/.asdf/installs/nodejs/22.2.0/bin/node
    Yarn: Not Found
    npm: 10.7.0 - /home/d11n/.asdf/installs/nodejs/22.2.0/bin/npm
    pnpm: Not Found
    bun: 1.2.10 - /usr/bin/bun
  Utilities:
    Git: 2.34.1 - /usr/bin/git
  Browsers:
    Chrome: 141.0.7390.122
    Firefox: 144.0.2
  npmPackages:
    @vuepress/bundler-vite: 2.0.0-rc.26 => 2.0.0-rc.26 
    @vuepress/bundler-webpack: Not Found
    @vuepress/cli:  2.0.0-rc.26 
    @vuepress/client:  2.0.0-rc.26 
    @vuepress/core:  2.0.0-rc.26 
    @vuepress/markdown:  2.0.0-rc.26 
    @vuepress/shared:  2.0.0-rc.26 
    @vuepress/utils:  2.0.0-rc.26 
    vue: ^3.5.23 => 3.5.23 
    vue-router:  4.6.3 
    vuepress: 2.0.0-rc.26 => 2.0.0-rc.26

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions