how to use craco with antd for theme switching?

Viewed 1676

I am trying to use Craco with Ant-Design but I am unable to make a proper theme switcher. Is there an easier way to implement a theme switcher for this?

const CracoLessPlugin = require("craco-less");
const {
    getThemeVariables
} = require('antd/dist/theme');

module.exports = {
    plugins: [{
        plugin: CracoLessPlugin,
        options: {
            lessLoaderOptions: {
                lessOptions: {
                    modifyVars: {
                        "@primary-color": "#1DA57A",
                        ...getThemeVariables({
                            dark: true,
                            compact: true
                        })
                    },
                    javascriptEnabled: true
                }
            }
        }
    }],
};
1 Answers
Related