-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
376c468
commit 1c548b3
Showing
2 changed files
with
25 additions
and
8 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
const fs = require('fs'); | ||
|
||
const data = fs.readFileSync('./static/libs/iclient-mapboxgl/iclient-mapboxgl.min.js', 'utf8'); | ||
if (data.includes('function(){try{return G6}catch(e){return {}}}()')) { | ||
const path = './static/libs/iclient-mapboxgl/iclient-mapboxgl.min.js'; | ||
const data = fs.readFileSync(path, 'utf8'); | ||
|
||
if (data.includes('function(){try{return G6}catch(e)')) { | ||
throw new Error('iclient-mapboxgl需要保留g6, 注释掉g6 extrenals手动打包!'); | ||
} | ||
if (data.includes('function(){try{return G2}catch(e){return {}}}()')) { | ||
if (data.includes('function(){try{return G2}catch(e)')) { | ||
throw new Error('iclient-mapboxgl需要保留g2, 注释掉g2 extrenals手动打包!'); | ||
} | ||
if (data.includes('function(){try{return L7}catch(e){return {}}}()')) { | ||
throw new Error('iclient-mapboxgl需要保留l7-render, 注释掉l7-render extrenals手动打包!') | ||
if (data.includes('function(){try{return L7}catch(e)')) { | ||
throw new Error('iclient-mapboxgl需要保留l7-render, 注释掉l7-render extrenals手动打包!'); | ||
} | ||
|
||
fs.promises | ||
.stat(path) | ||
.then(stats => { | ||
if (stats.isFile()) { | ||
if (stats.size < 4 * 1024 * 1024) { | ||
throw new Error('iclient-mapboxgl包体积过小,请检查g6、g2、l7-render是否被打包进来!'); | ||
} | ||
} else { | ||
throw new Error('路径指向的不是一个文件。'); | ||
} | ||
}) | ||
.catch(error => { | ||
console.error(error); | ||
}); |