import { prefix, version } from './src/utils/config';
import theme from './src/utils/theme';
const path = require('path');

export default {
  targets: {
    ie: 10,
  },
  dva: {},
  antd: {},
  dynamicImport: {
    loading: '@/components/Loading/index.tsx',
  },
  alias: {
    '@ant-design/icons/lib/dist$': path.resolve(__dirname, './src/icons.ts'),
  },
  chainWebpack(config) {
    config.merge({
      optimization: {
        splitChunks: {
          cacheGroups: {
            styles: {
              name: 'styles',
              test: /\.(css|less)$/,
              chunks: 'async',
              minChunks: 2,
              minSize: 0,
            },
            vendors: {
              name: 'vendors',
              test({ resource }) {
                return /[\\/]node_modules[\\/]/.test(resource);
              },
              priority: 10,
              chunks: 'all',
              minSize: 30000,
              minChunks: 3,
              automaticNameDelimiter: '.',
            },
          },
        },
      },
    });
  },
  ignoreMomentLocale: true,
  metas: [{ 'http-equiv': 'A-UA-Compatible', content: 'IE=Edge,chrome=1' }],
  title: '{{title}}',
  base: `/${prefix}`,
  publicPath: `/${prefix}/`,
  favicon: `/${prefix}/favicon.ico`,
  outputPath: `/dist-${version}/`,
  extraBabelPlugins: ['lodash'],
  plugins: ['lodash-webpack-plugin'],
  theme,
};
