123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- // https://umijs.org/config/
- import os from 'os';
- import slash from 'slash2';
- import pageRoutes from './router.config';
- import webpackPlugin from './plugin.config';
- import defaultSettings from '../src/defaultSettings';
- // import CompressionPlugin from 'compression-webpack-plugin';
- const { pwa, primaryColor } = defaultSettings;
- const { NODE_ENV, APP_TYPE, TEST } = process.env;
- const plugins = [
- [
- 'umi-plugin-react',
- {
- antd: true,
- dva: {
- hmr: true,
- },
- locale: {
- enable: false, // 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,
- level: 3,
- },
- pwa: pwa
- ? {
- workboxPluginMode: 'InjectManifest',
- workboxOptions: {
- importWorkboxFrom: 'local',
- },
- }
- : {},
- ...(!TEST && os.platform() === 'darwin'
- ? {
- dll: {
- include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
- exclude: ['@babel/runtime'],
- },
- hardSource: false,
- }
- : {}),
- },
- ],
- // [
- // 'compression-webpack-plugin'
- // ]
- ];
- // 针对 preview.pro.ant.design 的 GA 统计代码
- // 业务上不需要这个
- if (APP_TYPE === 'site') {
- plugins.push([
- 'umi-plugin-ga',
- {
- code: 'UA-72788897-6',
- },
- ]);
- }
- export default {
- hash: true,
- // add for transfer to umi
- plugins,
- base: '/bom/',
- publicPath: NODE_ENV == 'development' ? '/' : '/bom/',
- // base: '/',
- // publicPath: '/',
- history: 'hash',
- define: {
- APP_TYPE: APP_TYPE || '',
- // API_HOST: 'http://oraysmart.com:8888'
- },
- treeShaking: true,
- targets: {
- ie: 11,
- },
- // 路由配置
- routes: pageRoutes,
- // Theme for antd
- // https://ant.design/docs/react/customize-theme-cn
- theme: {
- 'primary-color': primaryColor,
- },
- // externals: {
- // bizcharts: 'BizCharts',
- // },
- externals: {
- // 'react': 'window.React',
- // 'react-dom': 'window.ReactDOM',
- // '@antv/g2': 'window.G2',
- // 'lodash': 'window.lodash',
- // 'antd/lib/index': 'window.antd',
- // 'antd/es/index': 'window.antd',
- // 'antd': 'window.antd',
- // 'moment': 'window.moment',
- // 'moment/moment': 'window.moment',
- // '@antv/data-set': 'DataSet',
- },
- // scripts: [
- // 'https://gw.alipayobjects.com/os/lib/react/16.13.1/umd/react.production.min.js',
- // 'https://gw.alipayobjects.com/os/lib/react-dom/16.13.1/umd/react-dom.production.min.js',
- // 'https://cdnjs.cloudflare.com/ajax/libs/antv-g2/3.5.19/g2.min.js',
- // ],
- ignoreMomentLocale: true,
- lessLoaderOptions: {
- javascriptEnabled: true,
- },
- disableRedirectHoist: 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 = 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,
- proxy: {
- '/api': {
- //target: 'http://192.168.20.152:8888/',
- target: 'http://47.96.12.136:8896/',
- // target: 'http://oraysmart.com:8889/',
- // target: 'http://oraysmart.com:8888/api',
- // changeOrigin: true,
- // pathRewrite: { '^/api': '' },
- },
- '/config': {
- target: 'http://127.0.0.1:8888/',
- //target: 'http://oraysmart.com:8888/',
- },
- '/device': {
- target: 'http://127.0.0.1:8888/',
- //target: 'http://oraysmart.com:8888/',
- },
- '/fs': {
- target: 'http://oraysmart.com:8888/',
- // target: 'http://oraysmart.com:8888/',
- },
- '/setting': {
- target: 'http://127.0.0.1:8888/',
- //target: 'http://oraysmart.com:8888/',
- },
- '/v1': {
- target: 'https://water-service.oss-cn-hangzhou.aliyuncs.com/',
- changeOrigin: true,
- ws: true,
- pathRewrite: {
- '^/v1': '',
- },
- },
- '/v2': {
- target: 'https://tz-server-res.oss-cn-beijing.aliyuncs.com/',
- changeOrigin: true,
- ws: true,
- pathRewrite: {
- '^/v2': '',
- },
- },
- },
- };
|