plugin.config.js 1.09 KB
Newer Older
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
1 2
// Change theme plugin

3
import MergeLessPlugin from 'antd-pro-merge-less';
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
4
import AntDesignThemePlugin from 'antd-theme-webpack-plugin';
5
import path from 'path';
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
6

7
export default config => {
8 9 10 11 12
  // pro ε’Œ εΌ€ε‘ηŽ―ε’ƒε†ζ·»εŠ θΏ™δΈͺ插仢
  if (process.env.APP_TYPE === 'site' || process.env.NODE_ENV !== 'production') {
    // ε°†ζ‰€ζœ‰ less εˆεΉΆδΈΊδΈ€δΈͺδΎ› themePlugin使用
    const outFile = path.join(__dirname, '../.temp/ant-design-pro.less');
    const stylesDir = path.join(__dirname, '../src/');
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
13

14 15 16 17 18 19
    config.plugin('merge-less').use(MergeLessPlugin, [
      {
        stylesDir,
        outFile,
      },
    ]);
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
20

21 22 23 24 25 26 27 28 29 30 31 32
    config.plugin('ant-design-theme').use(AntDesignThemePlugin, [
      {
        antDir: path.join(__dirname, '../node_modules/antd'),
        stylesDir,
        varFile: path.join(__dirname, '../node_modules/antd/lib/style/themes/default.less'),
        mainLessFile: outFile, //     themeVariables: ['@primary-color'],
        indexFileName: 'index.html',
        generateOne: true,
        lessUrl: 'https://gw.alipayobjects.com/os/lib/less.js/3.8.1/less.min.js',
      },
    ]);
  }
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
33
};