Commit d4c40abf authored by 杨思琦's avatar 杨思琦

fix: cesium升级相关修改

parent eb52a26a
Pipeline #71812 passed with stages
......@@ -2,6 +2,7 @@ const slash = require('slash2');
const proxy = require('./proxy');
const defaultSetting = require('./defaultSetting');
const cesiumBuild = '../node_modules/cesium/Build/Cesium';
const cesiumSource = '../node_modules/cesium/Source';
const pkgName = require('../package.json').name;
// eslint-disable-next-line import/order
const { NODE_ENV } = process.env;
......@@ -12,7 +13,6 @@ module.exports = {
// mfsu: {},
esbuild: {},
webpack5: {},
workerLoader: true,
base: '/civbase',
title: '熊猫智慧城市监控管理解决方案',
hash: true,
......@@ -53,21 +53,20 @@ module.exports = {
cssLoader: {
modules: {
getLocalIdent: (context, _, localName) => {
if (/@wisdom-cesium/.test(context.resourcePath)) {
const matchRule = slash(context.resourcePath).match(/@wisdom-cesium\/(krpano)(.*).less$/)
const matchRule = slash(context.resourcePath).match(/@wisdom-cesium\/(krpano)(.*).less$/);
if (matchRule && matchRule[2]) {
if (/rc-slider/.test(matchRule[0])) {
return localName
return localName;
}
const className = matchRule[2].
split('/')
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, '-')
.map(a => a.toLowerCase())
.join('-');
return `panda-krpano-${className}-${localName}`.replace(/--/g, '-');
}
return localName
return localName;
}
if (
......@@ -107,48 +106,24 @@ module.exports = {
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),
},
workerLoader: {},
copy: [
{
from: path.join(pkgName, cesiumBuild, './Workers'),
to: 'Workers',
},
{
from: path.join(pkgName, cesiumBuild, 'Assets'),
from: path.join(pkgName, cesiumSource, 'Assets'),
to: 'Assets',
},
{
from: path.join(pkgName, cesiumBuild, 'Widgets'),
from: path.join(pkgName, cesiumSource, 'Widgets'),
to: 'Widgets',
},
{
from: path.join(pkgName, cesiumBuild, 'ThirdParty'),
from: path.join(pkgName, cesiumSource, 'ThirdParty'),
to: 'ThirdParty',
},
],
define: {
// eslint-disable-next-line no-useless-escape
CESIUM_BASE_URL: JSON.stringify(CESIUM_BASE_URL).replace(/\"/g, ''),
},
alias: {
cesium: path.resolve(__dirname, cesiumBuild),
cesium: path.resolve(__dirname, cesiumSource),
'@esri/arcgis-html-sanitizer': path.resolve(
__dirname,
'../node_modules/@esri/arcgis-html-sanitizer/dist/esm/index.js',
......
......@@ -39,6 +39,7 @@ module.exports = {
mangle: {
safari10: true,
},
sourceMap: true,
output: {
ecma: 5,
comments: false,
......
/* eslint-disable no-underscore-dangle */
/* eslint-disable no-undef */
/* eslint-disable no-shadow */
/* eslint-disable global-require */
/* eslint-disable prettier/prettier */
const { deepmerge, createDebug, winPath, resolve } = require('@umijs/utils');
const { ESBuildPlugin, ESBuildMinifyPlugin } = require('esbuild-loader');
const fs = require('fs');
......@@ -175,7 +180,6 @@ module.exports = options => {
lockCoreJS3: {},
// import: (presetOpts.import || []).concat([{ libraryName: 'antd', libraryDirectory: 'es', style: true }]),
});
const babelOpts = {
sourceType: 'unambiguous',
babelrc: false,
......@@ -357,24 +361,8 @@ module.exports = options => {
chunks: defaultConfig.chunks ? defaultConfig.chunks : 'all',
};
const htmlPluginOptions = isDev
? {
...babelOpts,
}
: {
...baseHtmlOptions,
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
},
};
? { ...babelOpts }
: { ...baseHtmlOptions, minify: { removeComments: true, collapseWhitespace: true, removeRedundantAttributes: true, useShortDoctype: true, removeEmptyAttributes: true, removeStyleLinkTypeAttributes: true, keepClosingSlash: true, minifyJS: true, minifyCSS: true, minifyURLs: true }};
chainConfig.plugin('htmlPlugins').use(require.resolve('html-webpack-plugin'), [htmlPluginOptions]);
......@@ -514,14 +502,14 @@ module.exports = options => {
chainConfig.plugin('progress').use(require.resolve('webpackbar'), [
mfsu
? {
name: 'MFSU',
color: '#facc00',
}
name: 'MFSU',
color: '#facc00',
}
: defineConfig.ssr
? {
? {
name: type === 'ssr' ? 'Server' : 'Client',
}
: {},
: {},
]);
}
......@@ -561,15 +549,13 @@ module.exports = options => {
if (!isWebpack5) {
chainConfig.plugin('hash-module-ids').use(webpack.HashedModuleIdsPlugin, []);
}
chainConfig.optimization.minimize(process.env.NODE_ENV === 'production');
if (disableCompress) {
chainConfig.optimization.minimize(false);
} else if (!options.__disableTerserForTest) {
chainConfig.optimization.minimizer('terser').use(require.resolve('terser-webpack-plugin'), [
{
terserOptions: deepmerge(terserOptions, defineConfig.terserOptions || {}),
sourceMap: defineConfig.devtool !== false,
cache: process.env.TERSER_CACHE !== 'none',
parallel: true,
extractComments: false,
},
......@@ -634,7 +620,7 @@ module.exports = options => {
? { outputFormat: 'human', outputTarget: console.log }
: {
outputFormat: 'json',
outputTarget: join(process.cwd(), 'speed-measure.json'),
outputTarget: join(process.cwd(), 'speed-measure.json'),
};
const smp = new SpeedMeasurePlugin(smpOption);
ret = smp.wrap(ret);
......@@ -665,7 +651,10 @@ module.exports = options => {
}, {}),
http: false,
https: false,
zlib: false,
url: false
};
ret.resolve.mainFiles = ['index', 'Cesium'];
}
ret = {
......
......@@ -7,10 +7,7 @@ module.exports = require('./webpack.base.babel')({
mode: 'production',
// In production, we skip all hot-reloading stuff
entry: [
require.resolve('react-app-polyfill/ie11'),
path.join(process.cwd(), 'src/app.js'),
],
entry: [require.resolve('react-app-polyfill/ie11'), path.join(process.cwd(), 'src/app.js')],
// Utilize long-term caching by adding content hashes (not compilation hashes) to compiled assets
// output: {
......@@ -36,10 +33,9 @@ module.exports = require('./webpack.base.babel')({
comments: false,
ascii_only: true,
},
sourceMap: true,
},
parallel: true,
cache: true,
sourceMap: true,
}),
],
nodeEnv: 'production',
......@@ -53,8 +49,8 @@ module.exports = require('./webpack.base.babel')({
minSize: 20000,
minRemainingSize: 0,
minChunks: 1,
maxAsyncRequests: 30,// webpack4,5区别较大
maxInitialRequests: 30,// webpack4,5区别较大
maxAsyncRequests: 30, // webpack4,5区别较大
maxInitialRequests: 30, // webpack4,5区别较大
enforceSizeThreshold: 50000,
cacheGroups: {
vendor: {
......@@ -62,9 +58,7 @@ module.exports = require('./webpack.base.babel')({
maxInitialRequests: 5,
test: /[\\/]node_modules[\\/]/,
name(module) {
const packageName = module.context.match(
/[\\/]node_modules[\\/](.*?)([\\/]|$)/,
)[1];
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
return `npm.${packageName.replace('@', '')}`;
},
},
......@@ -106,7 +100,7 @@ module.exports = require('./webpack.base.babel')({
priority: 30,
test: /[\\/]node_modules[\\/]@arcgis[\\/]core[\\/]chunks[\\/]/,
name: 'arcgis_chunks',
}
},
},
},
},
......@@ -127,7 +121,6 @@ module.exports = require('./webpack.base.babel')({
],
performance: {
assetFilter: assetFilename =>
!/(\.map$)|(^(main\.|favicon\.))/.test(assetFilename),
assetFilter: assetFilename => !/(\.map$)|(^(main\.|favicon\.))/.test(assetFilename),
},
});
......@@ -15,6 +15,7 @@
"scripts": {
"init": "yarn install --registry=https://g.civnet.cn:4873",
"analyze:clean": "rimraf stats.json",
"debugger": "node --inspect-brk internals/webpack/build.js",
"preanalyze": "yarn run analyze:clean",
"analyze": "cross-env ANALYZE=1 npm run build",
"npmcheckversion": "node ./internals/scripts/npmcheckversion.js",
......@@ -106,7 +107,7 @@
"@babel/polyfill": "7.4.3",
"@babel/runtime": "^7.10.5",
"@esri/calcite-colors": "6.0.3",
"@wisdom-cesium/cesium": "^1.1.12",
"@wisdom-cesium/cesium": "^1.1.21",
"@wisdom-cesium/krpano": "1.0.29-52",
"@wisdom-components/basictable": "^1.5.16",
"@wisdom-components/empty": "^1.4.1",
......@@ -295,7 +296,7 @@
"swagger-ui-react": "^4.0.0-beta.4",
"swagger2openapi": "^7.0.5",
"swc-loader": "^0.1.15",
"terser-webpack-plugin": "1.2.3",
"terser-webpack-plugin": "5.2.0",
"traverse": "^0.6.6",
"umi-webpack-bundle-analyzer": "3.6.0",
"url-loader": "1.1.2",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment