.webpackrc.js 1.18 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 24 25
  },
  ignoreMomentLocale: true,
  theme: './src/theme.js',
  html: {
    template: './src/index.ejs',
  },
  publicPath: '/',
  hash: true,
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
26 27 28
  lessLoaderOptions: {
    javascriptEnabled: true,
  },
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
29 30 31
  cssLoaderOptions: {
    modules: true,
    getLocalIdent: (context, localIdentName, localName) => {
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
32 33 34 35
      if (
        context.resourcePath.includes('node_modules') ||
        context.resourcePath.includes('ant.design.pro.less')
      ) {
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
36 37
        return localName;
      }
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
38
      const antdProPath = context.resourcePath.match(/src(.*)/)[1].replace('.less', '');
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
39 40 41 42
      const arr = antdProPath
        .split('/')
        .map(a => a.replace(/([A-Z])/g, '-$1'))
        .map(a => a.toLowerCase());
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
43
      return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
44 45
    },
  },
niko's avatar
niko committed
46
};