webpack.config.js 932 B

12345678910111213141516171819202122232425262728293031
  1. import AntDesignThemePlugin from 'antd-theme-webpack-plugin';
  2. import MergeLessPlugin from './scripts/mergeLessPlugin';
  3. const path = require('path');
  4. export default webpackConfig => {
  5. // 将所有 less 合并为一个供 themePlugin使用
  6. const outFile = path.join(__dirname, './.temp/ant-design-pro.less');
  7. const stylesDir = path.join(__dirname, './src/');
  8. const mergeLessPlugin = new MergeLessPlugin({
  9. stylesDir,
  10. outFile,
  11. });
  12. const options = {
  13. antDir: path.join(__dirname, './node_modules/antd'),
  14. stylesDir,
  15. varFile: path.join(__dirname, './node_modules/antd/lib/style/themes/default.less'),
  16. mainLessFile: outFile,
  17. themeVariables: ['@primary-color'],
  18. indexFileName: 'index.html',
  19. };
  20. const themePlugin = new AntDesignThemePlugin(options);
  21. // in config object
  22. webpackConfig.plugins.push(mergeLessPlugin);
  23. webpackConfig.plugins.push(themePlugin);
  24. return webpackConfig;
  25. };