config.js 3.48 KB
Newer Older
1
const slash = require('slash2');
2
const proxy = require('./proxy');
3
const defaultSetting = require('./defaultSetting');
邓晓峰's avatar
邓晓峰 committed
4 5 6
const cesiumBuild = '../node_modules/cesium/Build/Cesium';
const pkgName = require('../package.json').name;
// eslint-disable-next-line import/order
7
const { NODE_ENV } = process.env;
邓晓峰's avatar
邓晓峰 committed
8
// eslint-disable-next-line import/order
邓晓峰's avatar
邓晓峰 committed
9 10
const path = require('path');
const CESIUM_BASE_URL = `/${pkgName}`;
11
module.exports = {
邓晓峰's avatar
邓晓峰 committed
12
  // mfsu: {},
邓晓峰's avatar
邓晓峰 committed
13
  esbuild: {},
邓晓峰's avatar
邓晓峰 committed
14
  webpack5: {},
邓晓峰's avatar
邓晓峰 committed
15
  workerLoader: true,
邓晓峰's avatar
邓晓峰 committed
16
  base: '/civbase',
17 18 19 20 21
  title: '熊猫智慧城市监控管理解决方案',
  hash: true,
  layout: {
    siderWidth: '145px',
    locale: true,
22
    ...defaultSetting,
23 24
  },
  fastRefresh: true,
邓晓峰's avatar
邓晓峰 committed
25
  useHash: true,
26 27 28 29 30 31 32 33 34 35 36 37 38
  locale: {
    default: 'zh-CN',
    antd: true,
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@ant-design/pro-layout/es/PageLoading',
  },
  // theme: {
  //   '@primary-color': '#ff9600',
  // },
  ignoreMomentLocale: true,
  nodeModulesTransform: {
邓晓峰's avatar
邓晓峰 committed
39
    type: 'none',
40
    exclude: ['@wisdom-map/arcgismap', '@wisdom-map/amap', '@wisdom-map/basemap', 'swagger-ui-react', 'Cesium'],
41
  },
42
  proxy: proxy[NODE_ENV],
43 44 45 46 47
  // openAPI: {
  //   requestLibPath: "import { request } from '@wisdom-utils/utils'",
  //   schemaPath: 'http://192.168.10.150:8777/Publish/OMS/swagger/v1/swagger.json',
  //   mock: false,
  // },
48 49 50 51 52 53 54 55
  postcssLoader: {},
  styleLoader: {},
  cssLoader: {
    modules: {
      getLocalIdent: (context, _, localName) => {
        if (
          context.resourcePath.includes('node_modules') ||
          context.resourcePath.includes('ant.design.pro.less') ||
邓晓峰's avatar
邓晓峰 committed
56 57
          context.resourcePath.includes('global.less') ||
          context.resourcePath.includes('ThemeColor.less')
58 59 60 61
        ) {
          return localName;
        }

邓晓峰's avatar
邓晓峰 committed
62
        const match = context.resourcePath.match(/(src(.*))/);
63 64 65 66 67 68 69

        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());
邓晓峰's avatar
邓晓峰 committed
70
          return `panda-console-base${arr.join('-')}-${localName}`.replace(/--/g, '-');
71 72 73 74 75
        }
        return localName;
      },
    },
  },
邓晓峰's avatar
邓晓峰 committed
76 77 78
  lessLoader: {
    modifyVars: {
      // hack: `true; @import "~@/global.less";`,
79
      '@ant-prefix': 'panda-console-base',
80
      '@iconPrefixCls': 'panda-console-base-icon',
邓晓峰's avatar
邓晓峰 committed
81
    },
82
    javascriptEnabled: true,
邓晓峰's avatar
邓晓峰 committed
83
  },
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
  copy: [
    {
      from: path.join(pkgName, cesiumBuild, './Workers'),
      to: 'Workers',
    },
    {
      from: path.join(pkgName, cesiumBuild, 'Assets'),
      to: 'Assets',
    },
    {
      from: path.join(pkgName, cesiumBuild, 'Widgets'),
      to: 'Widgets',
    },
    {
      from: path.join(pkgName, cesiumBuild, 'ThirdParty'),
      to: 'ThirdParty',
    },
邹绪超's avatar
邹绪超 committed
101
  ],
102 103
  define: {
    CESIUM_BASE_URL: JSON.stringify(CESIUM_BASE_URL).replace(/\"/g, ''),
邹绪超's avatar
邹绪超 committed
104 105
  },
  alias: {
106
    cesium: path.resolve(__dirname, cesiumBuild),
邹绪超's avatar
邹绪超 committed
107
  },
108
  workerLoader: {},
邓晓峰's avatar
邓晓峰 committed
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
  copy: [
    {
      from: path.join(pkgName, cesiumBuild, './Workers'),
      to: 'Workers',
    },
    {
      from: path.join(pkgName, cesiumBuild, 'Assets'),
      to: 'Assets',
    },
    {
      from: path.join(pkgName, cesiumBuild, 'Widgets'),
      to: 'Widgets',
    },
    {
      from: path.join(pkgName, cesiumBuild, 'ThirdParty'),
      to: 'ThirdParty',
    },
  ],
  define: {
    CESIUM_BASE_URL: JSON.stringify(CESIUM_BASE_URL).replace(/\"/g, ''),
  },
  alias: {
    cesium: path.resolve(__dirname, cesiumBuild),
  },

邓晓峰's avatar
邓晓峰 committed
134
  // esbuild: {}
135
};