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

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

ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
46
      let antdProPath = context.resourcePath.match(/src(.*)/)[1].replace('.less', '');
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
47 48 49 50 51 52 53 54 55 56
      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
57
};