config.js 3.51 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 41
    exclude: [
      '@wisdom-map/arcgismap',
lihonglin's avatar
lihonglin committed
42 43
      '@wisdom-map/Amap',
      '@wisdom-map/Map',
44
      'swagger-ui-react',
邓晓峰's avatar
邓晓峰 committed
45
      'Cesium',
46
    ],
47
  },
48
  proxy: proxy[NODE_ENV],
49 50 51 52 53
  // openAPI: {
  //   requestLibPath: "import { request } from '@wisdom-utils/utils'",
  //   schemaPath: 'http://192.168.10.150:8777/Publish/OMS/swagger/v1/swagger.json',
  //   mock: false,
  // },
54 55 56 57 58 59 60 61
  postcssLoader: {},
  styleLoader: {},
  cssLoader: {
    modules: {
      getLocalIdent: (context, _, localName) => {
        if (
          context.resourcePath.includes('node_modules') ||
          context.resourcePath.includes('ant.design.pro.less') ||
邓晓峰's avatar
邓晓峰 committed
62 63
          context.resourcePath.includes('global.less') ||
          context.resourcePath.includes('ThemeColor.less')
64 65 66 67
        ) {
          return localName;
        }

邓晓峰's avatar
邓晓峰 committed
68
        const match = context.resourcePath.match(/(src(.*))/);
69 70 71 72 73 74 75

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