config.js 4.29 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
  cssLoader: {
    modules: {
      getLocalIdent: (context, _, localName) => {
xuchaozou's avatar
xuchaozou committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72

        if (/@wisdom-cesium/.test(context.resourcePath)) {
    
          const matchRule = slash(context.resourcePath).match(/@wisdom-cesium\/(krpano)(.*).less$/)
          if (matchRule && matchRule[2]) {
            if (/rc-slider/.test(matchRule[0])) {
              return localName
            }
            const className = matchRule[2].
              split('/')
              .map(a => a.replace(/([A-Z])/g, '-$1'))
              .map(a => a.toLowerCase()).join('-')
            return `panda-krpano-${className}-${localName}`.replace(/--/g, '-')
          }
          return localName
        }

73 74 75
        if (
          context.resourcePath.includes('node_modules') ||
          context.resourcePath.includes('ant.design.pro.less') ||
邓晓峰's avatar
邓晓峰 committed
76 77
          context.resourcePath.includes('global.less') ||
          context.resourcePath.includes('ThemeColor.less')
78 79 80 81
        ) {
          return localName;
        }

邓晓峰's avatar
邓晓峰 committed
82
        const match = context.resourcePath.match(/(src(.*))/);
83 84 85 86 87 88 89

        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
90
          return `panda-console-base${arr.join('-')}-${localName}`.replace(/--/g, '-');
91 92 93 94 95
        }
        return localName;
      },
    },
  },
邓晓峰's avatar
邓晓峰 committed
96 97 98
  lessLoader: {
    modifyVars: {
      // hack: `true; @import "~@/global.less";`,
99
      '@ant-prefix': 'panda-console-base',
邓晓峰's avatar
邓晓峰 committed
100
      // '@iconPrefixCls': 'panda-console-base-icon',
邓晓峰's avatar
邓晓峰 committed
101
    },
102
    javascriptEnabled: true,
邓晓峰's avatar
邓晓峰 committed
103
  },
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
  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
121
  ],
122 123
  define: {
    CESIUM_BASE_URL: JSON.stringify(CESIUM_BASE_URL).replace(/\"/g, ''),
邹绪超's avatar
邹绪超 committed
124 125
  },
  alias: {
126
    cesium: path.resolve(__dirname, cesiumBuild),
邹绪超's avatar
邹绪超 committed
127
  },
128
  workerLoader: {},
邓晓峰's avatar
邓晓峰 committed
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
  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),
152 153 154 155
    '@esri/arcgis-html-sanitizer': path.resolve(
      __dirname,
      '../node_modules/@esri/arcgis-html-sanitizer/dist/esm/index.js',
    ),
邓晓峰's avatar
邓晓峰 committed
156 157
  },

邓晓峰's avatar
邓晓峰 committed
158
  // esbuild: {}
159
};