1
1
var configBase = require ( './webpack.config.base' ) ;
2
+ var fs = require ( 'fs' ) ;
3
+ const chalk = require ( 'chalk' ) ;
4
+ const minimist = require ( 'minimist' ) ;
2
5
//端名
3
6
var libName = 'openlayers' ;
4
7
//产品包名
5
8
var productName = 'iclient-openlayers' ;
6
9
7
- var argv = JSON . parse ( process . env [ 'npm_config_argv' ] ) ;
8
- var origin = argv . original ;
9
-
10
- if ( origin && origin . includes ( 'deploy-ol' ) ) {
10
+ const args = minimist ( process . argv . slice ( 2 ) ) ;
11
+ if (
12
+ args . _ . includes ( 'deploy-ol' ) ||
13
+ ( process . env . npm_lifecycle_event ?process . env . npm_lifecycle_event . includes ( 'deploy-ol' ) :false )
14
+ ) {
11
15
libName = 'ol' ;
12
16
productName = 'iclient-ol' ;
13
17
}
18
+
14
19
var externals = [
15
20
Object . assign ( { } , configBase . externals , {
16
21
'@turf/turf' : 'function(){try{return turf}catch(e){return {}}}()' ,
@@ -20,7 +25,6 @@ var externals = [
20
25
'luma.gl' : '(function(){try{return luma}catch(e){return {}}})()' ,
21
26
'webgl-debug' : '(function(){try{return webgl-debug}catch(e){return {}}})()' ,
22
27
xlsx : 'function(){try{return XLSX}catch(e){return {}}}()' ,
23
- canvg : 'function(){try{return canvg}catch(e){return {}}}()' ,
24
28
jsonsql : 'function(){try{return jsonsql}catch(e){return {}}}()' ,
25
29
three : 'function(){try{return THREE}catch(e){return {}}}()'
26
30
} ) ,
@@ -32,6 +36,23 @@ var externals = [
32
36
}
33
37
] ;
34
38
39
+ var methodNames = [ 'bindFeaturesCollection_' , 'addFeaturesInternal' ] ;
40
+ checkPrivateMethodExists ( methodNames ) ;
41
+
42
+ function checkPrivateMethodExists ( methodNames ) {
43
+ const file_path = 'node_modules/ol/dist/ol.js' ;
44
+ try {
45
+ const data = fs . readFileSync ( file_path , 'utf8' ) ;
46
+ methodNames . forEach ( ( methodName ) => {
47
+ if ( ! data . includes ( methodName ) ) {
48
+ console . log ( chalk . red ( `方法 ${ methodName } 不存在于混淆后的 ol 中 ${ file_path } ,测试 ol fgb 重写方法是否被调用` ) ) ;
49
+ }
50
+ } ) ;
51
+ } catch ( err ) {
52
+ console . error ( '读取文件出错:' , err ) ;
53
+ }
54
+ }
55
+
35
56
module . exports = {
36
57
target : configBase . target ,
37
58
mode : configBase . mode ,
0 commit comments