Skip to content

Commit 37414f7

Browse files
[feature]提供vue-iclient相关打包命令
AI-GEN: 70% Cursor
1 parent 9171bd0 commit 37414f7

8 files changed

Lines changed: 165 additions & 1 deletion

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
/package-lock.json
1111
.npmrc
1212
/dist/mapboxgl/resources/
13-
/dist/maplibregl/resources/
13+
/dist/maplibregl/resources/
14+
/custom-dist/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '../../src/common/mapping/WebMapV2Base';

build/custom/common.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { QueryBySQLParameters } from '../../src/common/iServer/QueryBySQLParameters';
2+
import { QueryByGeometryParameters } from '../../src/common/iServer/QueryByGeometryParameters';
3+
import { FilterParameter } from '../../src/common/iServer/FilterParameter';
4+
import { QueryBySQLService } from '../../src/common/iServer/QueryBySQLService';
5+
import { QueryService } from '../../src/common/iServer/QueryService';
6+
import { FetchRequest } from '../../src/common/util/FetchRequest';
7+
import { GetFeaturesBySQLParameters } from '../../src/common/iServer/GetFeaturesBySQLParameters';
8+
import { GetFeaturesBySQLService } from '../../src/common/iServer/GetFeaturesBySQLService';
9+
import { GetFeaturesByBoundsParameters } from '../../src/common/iServer/GetFeaturesByBoundsParameters';
10+
import { FeatureService } from '../../src/common/iServer/FeatureService';
11+
import { Util } from '../../src/common/commontypes/Util';
12+
import { ColorsPickerUtil } from '../../src/common/util/ColorsPickerUtil';
13+
import { GeometryPolygon, GeometryLinearRing, GeometryPoint } from '../../src/common/commontypes';
14+
import { mapboxFilterToQueryFilter } from '../../src/common/util/FilterCondition';
15+
16+
export {
17+
QueryBySQLParameters,
18+
QueryByGeometryParameters,
19+
FilterParameter,
20+
QueryBySQLService,
21+
QueryService,
22+
FetchRequest,
23+
GetFeaturesBySQLParameters,
24+
GetFeaturesBySQLService,
25+
GetFeaturesByBoundsParameters,
26+
FeatureService,
27+
Util,
28+
ColorsPickerUtil,
29+
GeometryPolygon,
30+
GeometryLinearRing,
31+
GeometryPoint,
32+
mapboxFilterToQueryFilter
33+
};

build/custom/externals.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Remove specified keys from externals so those dependencies are bundled.
3+
* @param {Object} externals
4+
* @param {string[]} omitList
5+
* @returns {Object}
6+
*/
7+
function omitExternals(externals, omitList = []) {
8+
const result = Object.assign({}, externals);
9+
omitList.forEach((key) => {
10+
delete result[key];
11+
});
12+
return result;
13+
}
14+
15+
/**
16+
* Parse omit list from env: VUE_ICLIENT_OMIT_EXTERNALS="@antv/g6,@antv/g2"
17+
* @param {string[]} defaultOmit
18+
* @returns {string[]}
19+
*/
20+
function parseOmitList(defaultOmit) {
21+
const env = process.env.VUE_ICLIENT_OMIT_EXTERNALS;
22+
if (!env) {
23+
return defaultOmit;
24+
}
25+
return env.split(',').map((item) => item.trim()).filter(Boolean);
26+
}
27+
28+
module.exports = {
29+
omitExternals,
30+
parseOmitList,
31+
COMMON_OMIT: ['@antv/g6'],
32+
MAPBOXGL_OMIT: ['./L7/l7-render', '@antv/g2']
33+
};
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// "deploy-common": "webpack --config ./build/webpack.config.common.js --color",
2+
3+
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
4+
5+
module.exports = {
6+
target: ['es6'],
7+
mode: 'production',
8+
//页面入口文件配置
9+
entry: [`${__dirname}/common-webmapv2base.js`],
10+
11+
output: {
12+
clean: true,
13+
path: `${__dirname}/../../custom-dist/iclient-common/`,
14+
filename: 'iclient-common-webmapv2base.js',
15+
chunkFormat: 'commonjs',
16+
libraryTarget: 'umd'
17+
},
18+
19+
//是否启用压缩
20+
optimization: {
21+
minimize: true,
22+
emitOnErrors: false
23+
},
24+
//不显示打包文件大小相关警告
25+
performance: {
26+
hints: false
27+
},
28+
29+
//其它解决方案配置
30+
resolve: {
31+
extensions: ['.js']
32+
},
33+
34+
module: {
35+
rules: [
36+
{
37+
test: [/\.js$/],
38+
exclude: /node_modules[\/\\]proj4/,
39+
loader: 'babel-loader',
40+
options: {
41+
presets: ['@babel/preset-env']
42+
}
43+
}
44+
]
45+
},
46+
47+
plugins: []
48+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// "deploy-common": "webpack --config ./build/webpack.config.common.js --color",
2+
module.exports = {
3+
target: ['es5'],
4+
mode: 'production',
5+
//页面入口文件配置
6+
entry: [`${__dirname}/common.js`],
7+
8+
output: {
9+
path: `${__dirname}/../../custom-dist/iclient-common/`,
10+
filename: `iclient-common.js`,
11+
chunkFormat:'commonjs',
12+
libraryTarget: 'umd'
13+
},
14+
15+
//是否启用压缩
16+
optimization: {
17+
minimize: true,
18+
emitOnErrors: false
19+
},
20+
//不显示打包文件大小相关警告
21+
performance: {
22+
hints: false
23+
},
24+
25+
//其它解决方案配置
26+
resolve: {
27+
extensions: ['.js']
28+
},
29+
30+
plugins: []
31+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const mapboxglConfig = require('../webpack.config.mapboxgl');
2+
const { omitExternals, parseOmitList, MAPBOXGL_OMIT, COMMON_OMIT } = require('./externals');
3+
const configBase = require('../webpack.config.base');
4+
5+
// mapboxglConfig.externals[0] = Object.assign({}, configBase.externals, mapboxglExternals)
6+
const [mapboxglExternals] = mapboxglConfig.externals;
7+
8+
module.exports = Object.assign({}, mapboxglConfig, {
9+
externals: [omitExternals(mapboxglExternals, parseOmitList(MAPBOXGL_OMIT.concat(COMMON_OMIT)))],
10+
output: Object.assign({}, configBase.output('iclient-mapboxgl', 'iclient-mapboxgl'), {
11+
path: `${__dirname}/../../custom-dist/iclient-mapboxgl/`,
12+
}),
13+
});

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
"build-docs-maplibregl": "rimraf ./docs/maplibregl && jsdoc -c ./build/jsdocs/maplibregl/docs.json -R ./build/jsdocs/maplibregl/index.md",
4949
"build-docs-classic": "rimraf ./docs/classic && jsdoc -c ./build/jsdocs/classic/docs.json -R ./build/jsdocs/classic/index.md",
5050
"pre-publish": "node ./build/publish.js --leaflet && node ./build/publish.js --openlayers && node ./build/publish.js --mapboxgl && node ./build/publish.js --maplibregl && node ./build/publish.js --classic",
51+
"deploy-custom-webmapv2base": "webpack --config ./build/custom/webpack.config.common-webmapv2base.js --color && rimraf ./custom-dist/iclient-common/iclient-common-webmapv2base.js.LICENSE.txt",
52+
"deploy-custom-common": "webpack --config ./build/custom/webpack.config.common.js --color && rimraf ./custom-dist/iclient-common/iclient-common.js.LICENSE.txt",
53+
"deploy-custom-mapboxgl-es5": "cross-env moduleVersion=es5 webpack --config ./build/custom/webpack.config.mapboxgl.js --color && uglifyjs ./custom-dist/iclient-mapboxgl/iclient-mapboxgl.js --ecma 5 --comments /iclient-/i -c -m -o ./custom-dist/iclient-mapboxgl/iclient-mapboxgl.min.js && cleancss -o ./custom-dist/iclient-mapboxgl/iclient-mapboxgl.min.css ./custom-dist/iclient-mapboxgl/iclient-mapboxgl.css && rimraf ./custom-dist/iclient-mapboxgl/iclient-mapboxgl.js ./custom-dist/iclient-mapboxgl/iclient-mapboxgl.css",
54+
"deploy-custom-mapboxgl": "npm run deploy-custom-webmapv2base && npm run deploy-custom-common && npm run deploy-custom-mapboxgl-es5",
5155
"publish": "npm run pre-publish && cd ./src/common && npm publish && cd ../leaflet && npm publish && cd ../openlayers && npm publish && cd ../mapboxgl && npm publish && cd ../maplibregl && npm publish && cd ../classic && npm publish"
5256
},
5357
"keywords": [

0 commit comments

Comments
 (0)