webpack.config.js 926 Bytes
Newer Older
jim's avatar
jim committed
1
import AntDesignThemePlugin from 'antd-theme-webpack-plugin';
2
import MergeLessPlugin from 'antd-pro-merge-less';
jim's avatar
jim committed
3 4 5 6

const path = require('path');

export default webpackConfig => {
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
7
  // ๅฐ†ๆ‰€ๆœ‰ less ๅˆๅนถไธบไธ€ไธชไพ› themePluginไฝฟ็”จ
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
8
  const outFile = path.join(__dirname, './.temp/ant-design-pro.less');
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
9 10 11 12 13 14 15
  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;
};