GitOfZGT / dynamic-theme-demos

Implementing dynamic themes using plugins
50 stars 28 forks source link

Can't switch between themes when arbitraryMode = true #5

Open zmx0142857 opened 2 years ago

zmx0142857 commented 2 years ago

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.

GitOfZGT commented 2 years ago

Preset mode and any mode cannot coexist now.