plugin.config.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Change theme plugin
  2. import MergeLessPlugin from 'antd-pro-merge-less';
  3. import AntDesignThemePlugin from 'antd-theme-webpack-plugin';
  4. import path from 'path';
  5. export default config => {
  6. // pro 和 开发环境再添加这个插件
  7. if (process.env.APP_TYPE === 'site' || process.env.NODE_ENV !== 'production') {
  8. // 将所有 less 合并为一个供 themePlugin使用
  9. const outFile = path.join(__dirname, '../.temp/ant-design-pro.less');
  10. const stylesDir = path.join(__dirname, '../src/');
  11. config.plugin('merge-less').use(MergeLessPlugin, [
  12. {
  13. stylesDir,
  14. outFile,
  15. },
  16. ]);
  17. config.plugin('ant-design-theme').use(AntDesignThemePlugin, [
  18. {
  19. antDir: path.join(__dirname, '../node_modules/antd'),
  20. stylesDir,
  21. varFile: path.join(__dirname, '../node_modules/antd/lib/style/themes/default.less'),
  22. mainLessFile: outFile, // themeVariables: ['@primary-color'],
  23. indexFileName: 'index.html',
  24. generateOne: true,
  25. lessUrl: 'https://gw.alipayobjects.com/os/lib/less.js/3.8.1/less.min.js',
  26. },
  27. ]);
  28. }
  29. };