A webpack plugin that enables dynamic theme switching for Ant Design (antd) by generating color-specific Less/CSS files and injecting them into index.html. Version 1.3.9, stable but in maintenance mode; last updated in 2020. Works with webpack 4 or 5. Key differentiator: allows runtime theme variable changes (like @primary-color) without rebuilding the app, unlike compile-time theme customization. Uses client-side Less.js to recompile styles in the browser. Requires JavaScript enabled in less-loader and specific project structure.
npm install antd-theme-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Initializes the plugin with required options: antDir, stylesDir, varFile, themeVariables. Includes typical webpack config setup.
Add { javascriptEnabled: true } to less-loader options in webpack config.Add required HTML tags to your index.html.
Use webpack 4 or apply manual webpack 5 compatibility patches.
Consider alternatives like antd-theme-generator or use Ant Design's built-in ConfigProvider for CSS variables.
Set generateOnce: true in development to avoid repeated processing.
Add antDir: path.join(__dirname, './node_modules/antd') to the options object.
Use webpack 4 or find a webpack 5 compatible fork/plugin.
Ensure index.html includes <link rel="stylesheet/less" type="text/css" href="/color.less" /> and <script>window.less = { async: false, env: 'production' };</script> followed by less.js CDN.Set correct publicPath option matching your dev server's output path.