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

fix: cesium升级相关修改

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