123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- import defaultSettings from './defaultSettings'; // https://umijs.org/config/
-
- import slash from 'slash2';
- import webpackPlugin from './plugin.config';
- import routes from './routes';
- import proxy from './proxy';
-
- const path = require('path');
-
- const { pwa, primaryColor } = defaultSettings; // 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 } = process.env;
- const isAntDesignProPreview = ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site';
- const plugins = [
- [
- 'umi-plugin-react',
- {
- antd: true,
- dva: {
- hmr: true,
- },
- locale: {
- // default false
- enable: true,
- // default zh-CN
- default: 'zh-CN',
- // default true, when it is true, will use `navigator.language` overwrite default
- baseNavigator: true,
- },
- dynamicImport: {
- loadingComponent: './components/PageLoading/index',
- webpackChunkName: true,
- level: 3,
- },
- pwa: pwa
- ? {
- workboxPluginMode: 'InjectManifest',
- workboxOptions: {
- importWorkboxFrom: 'local',
- },
- }
- : false, // default close dll, because issue https://github.com/ant-design/ant-design-pro/issues/4665
- // dll features https://webpack.js.org/plugins/dll-plugin/
- // dll: {
- // include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
- // exclude: ['@babel/runtime', 'netlify-lambda'],
- // },
- },
- ],
- [
- 'umi-plugin-pro-block',
- {
- moveMock: false,
- moveService: false,
- modifyRequest: true,
- autoAddMenu: true,
- },
- ],
- ]; // 针对 preview.pro.ant.design 的 GA 统计代码
-
- if (isAntDesignProPreview) {
- plugins.push([
- 'umi-plugin-ga',
- {
- code: 'UA-72788897-6',
- },
- ]);
- plugins.push([
- 'umi-plugin-pro',
- {
- serverUrl: 'https://ant-design-pro.netlify.com',
- },
- ]);
- }
-
- export default {
- plugins,
- block: {
- // 国内用户可以使用码云
- // defaultGitUrl: 'https://gitee.com/ant-design/pro-blocks',
- defaultGitUrl: 'https://github.com/ant-design/pro-blocks',
- },
- hash: true,
- targets: {
- ie: 11,
- },
- publicPath: './',
- // process.env.PROD_ENV == 1 ? 'https://estateagents.oss-accelerate.aliyuncs.com/zhiyun/admin/' : './',
- // publicPath: 'https://njcjweb.oss-accelerate.aliyuncs.com/admin/',
- history: 'hash',
- devtool: isAntDesignProPreview ? 'source-map' : false,
- // umi routes: https://umijs.org/zh/guide/router.html
- routes,
- // Theme for antd: https://ant.design/docs/react/customize-theme-cn
- theme: {
- 'primary-color': primaryColor,
- 'btn-primary-bg': '#1890ff',
- 'table-row-hover-bg': '#eee',
- 'btn-danger-bg': '#FF7E48',
- 'radio-button-hover-color': '#FF7E48',
- 'radio-button-active-color': 'red',
- 'checkbox-color': '#1890ff',
- // 'checkbox-check-color': '#1890ff',
- 'checkbox-check-bg': '#1890ff',
- // @checkbox-check-bg: @checkbox-check-color;
- 'primary-1': '#eee'
- },
- define: {
- 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,
- lessLoaderOptions: {
- javascriptEnabled: true,
- },
- disableRedirectHoist: true,
- cssLoaderOptions: {
- modules: true,
- getLocalIdent: (context, _, localName) => {
- 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 = slash(antdProPath)
- .split('/')
- .map(a => a.replace(/([A-Z])/g, '-$1'))
- .map(a => a.toLowerCase());
- return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
- }
-
- return localName;
- },
- },
- manifest: {
- basePath: '/',
- },
- chainWebpack: webpackPlugin,
-
- alias: {
- '@/': path.resolve(__dirname, 'src/')
- },
-
- proxy,
- };
|