123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- // https://umijs.org/config/
- import { defineConfig, utils } from 'umi';
- import defaultSettings from './defaultSettings';
- import proxy from './proxy';
- import webpackPlugin from './plugin.config';
- const { winPath } = utils; // preview.pro.ant.design only do not use in your production ;
- // preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
- const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION, REACT_APP_ENV, GA_KEY } = process.env;
- export default defineConfig({
- history: {
- type: 'hash',
- },
- // 默认是 browser
- hash: true,
- antd: {},
- analytics: GA_KEY
- ? {
- ga: GA_KEY,
- }
- : false,
- dva: {
- hmr: true,
- },
- locale: {
- // default zh-CN
- default: 'zh-CN',
- // default true, when it is true, will use `navigator.language` overwrite default
- antd: true,
- baseNavigator: true,
- },
- dynamicImport: {
- loading: '@/components/PageLoading/index',
- },
- targets: {
- ie: 11,
- },
- // umi routes: https://umijs.org/docs/routing
- routes: [
- {
- path: '/user',
- component: '../layouts/UserLayout',
- routes: [
- {
- name: 'login',
- path: '/user/login',
- component: './user/login',
- },
- {
- name: '注册页',
- icon: 'smile',
- path: '/user/register',
- component: './user/Register',
- },
- ],
- },
- {
- path: '/',
- component: '../layouts/SecurityLayout',
- routes: [
- {
- path: '/',
- component: '../layouts/BasicLayout',
- // authority: ['admin', 'user'],
- routes: [
- {
- path: '/',
- redirect: '/memory',
- }, // {
- // path: '/welcome',
- // name: 'welcome',
- // icon: 'smile',
- // component: './Welcome',
- // },
- // {
- // path: '/admin',
- // name: 'admin',
- // icon: 'crown',
- // component: './Admin',
- // authority: ['admin'],
- // routes: [
- // {
- // path: '/admin/sub-page',
- // name: 'sub-page',
- // icon: 'smile',
- // component: './Welcome',
- // authority: ['admin'],
- // },
- // ],
- // },
- // {
- // name: 'list.table-list',
- // icon: 'table',
- // path: '/list',
- // component: './ListTableList',
- // },
- {
- name: 'list.memory',
- icon: 'smile',
- path: '/memory',
- component: './Memory',
- },
- {
- name: 'list.memoryList',
- icon: 'smile',
- path: '/memoryList',
- component: './MemoryList',
- },
- {
- name: 'list.setting',
- icon: 'smile',
- path: '/setting',
- component: './Setting',
- },
- {
- name: 'list.userList',
- icon: 'smile',
- path: '/userList',
- authority: ['1'],
- component: './UserList',
- },
- {
- component: './404',
- },
- ],
- },
- {
- component: './404',
- },
- ],
- },
- {
- component: './404',
- },
- ],
- // Theme for antd: https://ant.design/docs/react/customize-theme-cn
- theme: {
- // ...darkTheme,
- 'primary-color': defaultSettings.primaryColor,
- },
- define: {
- REACT_APP_ENV: REACT_APP_ENV || false,
- ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION:
- ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION || '', // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
- },
- ignoreMomentLocale: true,
- lessLoader: {
- javascriptEnabled: true,
- },
- cssLoader: {
- modules: {
- getLocalIdent: (
- context: {
- resourcePath: string;
- },
- _: string,
- localName: string
- ) => {
- if (
- context.resourcePath.includes('node_modules') ||
- context.resourcePath.includes('ant.design.pro.less') ||
- context.resourcePath.includes('global.less')
- ) {
- return localName;
- }
- const match = context.resourcePath.match(/src(.*)/);
- if (match && match[1]) {
- const antdProPath = match[1].replace('.less', '');
- const arr = winPath(antdProPath)
- .split('/')
- .map((a: string) => a.replace(/([A-Z])/g, '-$1'))
- .map((a: string) => a.toLowerCase());
- return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
- }
- return localName;
- },
- },
- },
- manifest: {
- basePath: '/',
- },
- proxy: proxy[REACT_APP_ENV || 'dev'],
- chainWebpack: webpackPlugin, // scripts: [
- // 'https://unpkg.com/react@16.8.6/umd/react.production.min.js',
- // 'https://unpkg.com/react-dom@16.8.6/umd/react-dom.production.min.js',
- // 'https://unpkg.com/bizcharts@3.5.5/umd/BizCharts.min.js',
- // 'https://cdn.bootcss.com/antd/4.0.0/antd.min.js',
- // ],
- // externals: {
- // react: 'React',
- // antd: 'antd',
- // 'react-dom': 'ReactDOM',
- // bizcharts: 'BizCharts',
- // },
- });
|