import os from 'os'; import { resolve } from 'path'; import pageRoutes from './router.config'; import webpackplugin from './plugin.config'; import defaultSettings from '../src/defaultSettings'; const fs = require('fs'); const path = require('path'); const lessToJs = require('less-vars-to-js'); const THEME_DARK_VARS = lessToJs( fs.readFileSync(path.join(__dirname, '../src/themes/dark/dark.style.less'), 'utf8') ); const THEME_LIGHT_VARS = lessToJs( fs.readFileSync(path.join(__dirname, '../src/themes/light/light.style.less'), 'utf8') ); const THEME_LIGHT_BLUE_VARS = lessToJs( fs.readFileSync(path.join(__dirname, '../src/themes/lightblue/lightblue.style.less'), 'utf8') ); 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 }, dynamicImport: { loadingComponent: './components/PageLoading/index', webpackChunkName: true, }, ...(!process.env.TEST && os.platform() === 'darwin' ? { dll: { include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'], exclude: ['@babel/runtime', 'react-dev-utils'], }, hardSource: false, } : {}), }, ], ], targets: { ie: 11, }, define: { __modulename: 'hrv', APP_TYPE: process.env.APP_TYPE || '', PRODUCTION: process.env.NODE_ENV || '', THEME_DARK_VARS, THEME_LIGHT_VARS, THEME_LIGHT_BLUE_VARS }, // 路由配置 routes: pageRoutes, // Theme for antd // https://ant.design/docs/react/customize-theme-cn theme: { 'icon-url': "'/HiatmpPro/iconfont/iconfont'", 'slide-bar-gr': '#172238', 'primary-color': '#148def', 'text-white': '#fffffc', 'text-color': '#fffffe', 'heading-color': '#fffffe', 'heading-color-dark ': '#fffffe', 'text-color-secondary-dark': '#fffffe', 'border-radius-base': '0', 'border-color-base': '#2870d3', 'border-color-split': '#2870d2', 'body-background': '#071633', 'component-background-light': '#142a59', 'component-background-hrv': '#0d1c46', 'component-background': '#0a1d3f', 'layout-body-background': '#09102f', 'btn-default-bg': 'rgba(0, 0, 0, 0.15)', 'outline-bg': 'rgba(11, 32, 68, 0.7)', 'component-inner-background': '#0c234c', 'component-inner2-background': '#2d4e7c', 'input-bg': '#0a1d3f', 'font-family': '"Microsoft Yahei", "微软雅黑",Arial, sans-serif', 'tableoddRow': '#182f61', 'tableevenRow': '#224684' }, /* externals: { '@antv/data-set': 'DataSet', }, */ 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') || 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 = antdProPath .split(`${path.sep}`) .map(a => a.replace(/([A-Z])/g, '-$1')) .map(a => a.toLowerCase()); return `himap${arr.join('-')}-${localName}`.replace(/--/g, '-'); } return localName; }, }, manifest: { name: 'himap', background_color: '#FFF', description: 'umi hiatmp', display: 'standalone', start_url: '/index.html', icons: [ { src: '/favicon.ico', sizes: '48x48', type: 'image/png', }, ], }, /* 注释这个样式会有问题,调试功能时候可以注释 antd-pro 项目热更新慢并且是在 95% (emitting) 时卡住怎么办? https://github.com/umijs/umi/issues/1421#issuecomment-438169125*/ chainWebpack: webpackplugin, publicPath: '/HiatmpPro/', alias: { components: resolve(__dirname, '../src/components'), themes: resolve(__dirname, '../src/themes'), }, /** 开发模式下的路由配置 */ proxy: { '/hrvfake': { target: 'http://10.16.3.178:8180', changeOrigin: true, pathRewrite: { '^/hrvfake/': '/eolinker_os/Mock/mock?projectID=12&uri=/', }, }, '/HiatmpPro/hrv': { // target: 'http://10.18.221.138:8083/', target: 'http://10.18.221.138:8080/', // target: 'http://10.18.221.137:999/', // target: 'http://10.16.5.98:8086', // target: "http://10.18.221.137:8086", changeOrigin: true, }, '/HiatmpPro/ddm': { // target: 'http://10.18.221.138:8090', target: 'http://10.18.221.138:8080', changeOrigin: true, }, '/HiatmpPro/tle': { target: 'http://10.16.1.56:8083', changeOrigin: true, }, '/HiatmpPro/scs': { target: 'http://10.16.1.56:8083', changeOrigin: true, }, '/HiatmpPro/HiMap': { // target: 'http://10.16.1.56:86', target: 'http://10.18.221.138:9499', changeOrigin: true, pathRewrite: { '^/HiatmpPro': '/', }, }, '/HiatmpPro/static': { target: 'http://10.16.4.26:8000', changeOrigin: true, pathRewrite: { '^/HiatmpPro': '/', }, }, "/HiatmpPro/psd": { target: "http://10.16.5.98:8088/", changeOrigin: true, }, '/HiatmpPro': { // target: 'http://10.16.5.98:81', target: 'http://10.18.221.138:8080', changeOrigin: true, }, '/fake': { target: 'http://10.16.3.178:8180', changeOrigin: true, pathRewrite: { '^/fake/': '/eolinker_os/Mock/mock?projectID=2&uri=/', }, }, }, history: 'hash', hash: true, };