config.js 1.53 KB
Newer Older
愚道's avatar
愚道 committed
1 2
/* eslint-disable react/destructuring-assignment */

愚道's avatar
愚道 committed
3
// https://umijs.org/config/
愚道's avatar
愚道 committed
4 5 6

const path = require('path');

愚道's avatar
愚道 committed
7
export default {
愚道's avatar
愚道 committed
8 9 10 11 12 13 14 15 16 17 18
  // add for transfer to umi
  plugins: [
    'umi-plugin-dva',
    [
      'umi-plugin-routes',
      {
        exclude: [/\.test\.js/],
      },
    ],
  ],
  disableServiceWorker: true,
愚道's avatar
愚道 committed
19

愚道's avatar
愚道 committed
20 21 22
  // copy from old webpackrc.js

  // entry: 'src/index.js', // TODO remove
愚道's avatar
愚道 committed
23 24 25 26 27 28 29 30 31 32 33 34
  extraBabelPlugins: [['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }]],
  env: {
    development: {
      extraBabelPlugins: ['dva-hmr'],
    },
  },
  externals: {
    '@antv/data-set': 'DataSet',
    bizcharts: 'BizCharts',
    rollbar: 'rollbar',
  },
  alias: {
愚道's avatar
愚道 committed
35
    components: path.resolve(__dirname, '../src/components/'),
愚道's avatar
愚道 committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
  },
  ignoreMomentLocale: true,
  theme: './src/theme.js',
  html: {
    template: './src/index.ejs',
  },
  publicPath: '/',
  // TODO check hash config
  // hash: true,
  lessLoaderOptions: {
    javascriptEnabled: true,
  },
  cssLoaderOptions: {
    modules: true,
    getLocalIdent: (context, localIdentName, localName) => {
      if (
        context.resourcePath.includes('node_modules') ||
        context.resourcePath.includes('ant.design.pro.less')
      ) {
        return localName;
      }
      const antdProPath = context.resourcePath.match(/src(.*)/)[1].replace('.less', '');
      const arr = antdProPath
        .split('/')
        .map(a => a.replace(/([A-Z])/g, '-$1'))
        .map(a => a.toLowerCase());
      return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
    },
  },
愚道's avatar
愚道 committed
65
};