.webpackrc.js 1.33 KB
Newer Older
niko's avatar
niko committed
1 2 3 4
const path = require('path');

export default {
  entry: 'src/index.js',
5
  extraBabelPlugins: [['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }]],
niko's avatar
niko committed
6 7 8 9 10
  env: {
    development: {
      extraBabelPlugins: ['dva-hmr'],
    },
  },
11 12 13 14 15
  externals: {
    '@antv/data-set': 'DataSet',
    bizcharts: 'BizCharts',
    rollbar: 'rollbar',
  },
niko's avatar
niko committed
16
  alias: {
jim's avatar
jim committed
17
    components: path.resolve(__dirname, 'src/components/'),
niko's avatar
niko committed
18
  },
19 20 21 22 23
  externals: {
    '@antv/data-set': 'DataSet',
    bizcharts: 'BizCharts',
    rollbar: 'rollbar',
  },
niko's avatar
niko committed
24 25 26 27 28 29 30
  ignoreMomentLocale: true,
  theme: './src/theme.js',
  html: {
    template: './src/index.ejs',
  },
  publicPath: '/',
  hash: true,
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
31 32 33
  lessLoaderOptions: {
    javascriptEnabled: true,
  },
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
34 35 36 37 38 39 40
  cssLoaderOptions: {
    modules: true,
    getLocalIdent: (context, localIdentName, localName) => {
      if (context.resourcePath.includes('node_modules')) {
        return localName;
      }

ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
41
      let antdProPath = context.resourcePath.match(/src(.*)/)[1].replace('.less', '');
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
42 43 44 45 46 47 48 49 50 51
      if (context.resourcePath.includes('components')) {
        antdProPath = antdProPath.replace('components/', '');
      }
      const arr = antdProPath
        .split('/')
        .map(a => a.replace(/([A-Z])/g, '-$1'))
        .map(a => a.toLowerCase());
      return `antd-pro${arr.join('-')}-${localName}`.replace('--', '-');
    },
  },
niko's avatar
niko committed
52
};