dynamic-theme-demos icon indicating copy to clipboard operation
dynamic-theme-demos copied to clipboard

Can't switch between themes when arbitraryMode = true

Open zmx0142857 opened this issue 2 years ago • 1 comments

Hello, is it possible to switch between themes when arbitraryMode = true?

When running the "webpack-react-antd-dynamic-theme" demo in this repo, I noticed that when arbitraryMode = true is set in the config of ThemeCssExtractWebpackPlugin, the html tag does not contain theme info like class="theme-mauve", and I cannot switch between the themes defined in multipleScopeVars array.

When I comment out arbitraryMode = true, then the themes are working but now I cannot set arbitrary theme color.

getDynamicThemePluginConfig.js

const multipleScopeVars = [
  {
    // 必需
    scopeName: "theme-mauve",
    // path和varsContent选一个
    path: path.resolve("src/theme/mauve-vars.less"),
    // varsContent:`@--color-primary:#9c26b;`
  },
  {
    scopeName: 'theme-second',
    path: path.resolve('src/theme/second-vars.less'),
  }
];

// ...
new ThemeCssExtractWebpackPlugin({
  // 以下是任意主题模式的参数 arbitraryMode:true 有效
  // arbitraryMode: true,
  // ...
})

Any help is appreciated, thank you.

zmx0142857 avatar Jun 18 '22 09:06 zmx0142857

Preset mode and any mode cannot coexist now.

GitOfZGT avatar Jun 18 '22 10:06 GitOfZGT