webpack.config.js 931 Bytes
Newer Older
jim's avatar
jim committed
1
import AntDesignThemePlugin from 'antd-theme-webpack-plugin';
陈帅's avatar
陈帅 committed
2
import MergeLessPlugin from './scripts/mergeLessPlugin';
jim's avatar
jim committed
3 4 5 6

const path = require('path');

export default webpackConfig => {
陈帅's avatar
陈帅 committed
7 8 9 10 11 12 13 14 15
  // 将所有 less 合并为一个供 themePlugin使用
  const outFile = path.join(__dirname, './temp/ant-design-pro.less');
  const stylesDir = path.join(__dirname, './src/');

  const mergeLessPlugin = new MergeLessPlugin({
    stylesDir,
    outFile,
  });

jim's avatar
jim committed
16 17
  const options = {
    antDir: path.join(__dirname, './node_modules/antd'),
陈帅's avatar
陈帅 committed
18
    stylesDir,
jim's avatar
jim committed
19
    varFile: path.join(__dirname, './node_modules/antd/lib/style/themes/default.less'),
陈帅's avatar
陈帅 committed
20
    mainLessFile: outFile,
jim's avatar
jim committed
21 22 23 24
    themeVariables: ['@primary-color'],
    indexFileName: 'index.html',
  };
  const themePlugin = new AntDesignThemePlugin(options);
陈帅's avatar
陈帅 committed
25

jim's avatar
jim committed
26
  // in config object
陈帅's avatar
陈帅 committed
27
  webpackConfig.plugins.push(mergeLessPlugin);
jim's avatar
jim committed
28
  webpackConfig.plugins.push(themePlugin);
陈帅's avatar
陈帅 committed
29

jim's avatar
jim committed
30 31
  return webpackConfig;
};