config.js 3.7 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
  locale: {
    default: 'zh-CN',
    antd: true,
    baseNavigator: true,
  },
  dynamicImport: {
邓晓峰's avatar
邓晓峰 committed
32
    loading: '@wisdom-utils/components/lib/AppLayout/components/PageLoading',
33 34 35 36 37 38
  },
  // 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],
邓晓峰's avatar
邓晓峰 committed
43 44 45
  theme: {
    'root-entry-name': 'variable',
  },
46 47 48 49 50
  // openAPI: {
  //   requestLibPath: "import { request } from '@wisdom-utils/utils'",
  //   schemaPath: 'http://192.168.10.150:8777/Publish/OMS/swagger/v1/swagger.json',
  //   mock: false,
  // },
51
  postcssLoader: {},
邓晓峰's avatar
邓晓峰 committed
52
  // styleLoader: {},
53 54 55 56 57 58
  cssLoader: {
    modules: {
      getLocalIdent: (context, _, localName) => {
        if (
          context.resourcePath.includes('node_modules') ||
          context.resourcePath.includes('ant.design.pro.less') ||
邓晓峰's avatar
邓晓峰 committed
59 60
          context.resourcePath.includes('global.less') ||
          context.resourcePath.includes('ThemeColor.less')
61 62 63 64
        ) {
          return localName;
        }

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

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

邓晓峰's avatar
邓晓峰 committed
141
  // esbuild: {}
142
};