/* eslint-disable react/destructuring-assignment */ // https://umijs.org/config/ const pageRoutes = require('./router.config'); const path = require('path'); export default { // add for transfer to umi plugins: [ ['umi-plugin-react', { antd: true, dva: { hmr: true, }, locale: { enable: true, // default false default: 'zh-CN', // default zh-CN baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default }, dll: [ 'dva', 'dva/router', 'dva/saga', 'dva/fetch', ], }], ], // 路由配置 routes: pageRoutes, theme: { 'card-actions-background': '#f5f8fa', }, externals: { '@antv/data-set': 'DataSet', rollbar: 'rollbar', }, alias: { components: path.resolve(__dirname, '../src/components/'), utils: path.resolve(__dirname, '../src/utils/'), assets: path.resolve(__dirname, '../src/assets/'), common: path.resolve(__dirname, '../src/common/'), }, ignoreMomentLocale: 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 match = context.resourcePath.match(/src(.*)/); if (match && match[1]) { const antdProPath = match[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, '-'); } else { return localName; } }, }, manifest: { name: 'ant-design-pro', background_color: '#FFF', description: 'An out-of-box UI solution for enterprise applications as a React boilerplate.', display: 'standalone', start_url: '/index.html', icons: [ { src: '/favicon.png', sizes: '48x48', type: 'image/png', }, ], }, chainWebpack(config) { const AntDesignThemePlugin = require('antd-theme-webpack-plugin'); const MergeLessPlugin = require('antd-pro-merge-less'); // 将所有 less 合并为一个供 themePlugin使用 const outFile = path.join(__dirname, './.temp/ant-design-pro.less'); const stylesDir = path.join(__dirname, './src/'); // config // .plugin('merge-less') // .use(MergeLessPlugin, [{ // stylesDir, // outFile, // }]); // config // .plugin('ant-design-theme') // .use(AntDesignThemePlugin, [{ // antDir: path.join(__dirname, './node_modules/antd'), // stylesDir, // varFile: path.join(__dirname, './node_modules/antd/lib/style/themes/default.less'), // mainLessFile: outFile, // themeVariables: ['@primary-color'], // indexFileName: 'index.html', // }]); }, };