根据Webpack docs,
splitChunks.minChunks
在拆分之前必须共享模块的最小块数。
因此,由于默认值为1,所以我添加了 takePicture() {
const options = {};
//options.location = ...
this.camera.capture({ metadata: options })
.then((data) => {
let pathToImage = data.path;
CompressImage.createCompressedImage(pathToImage, 'compress/images').then(
ImgToBase64.getBase64String(pathToImage)
.then(base64String => {
**base64String = "data:image/jpg;base64," + base64String;**//This gives the base64 of the image
alert(base64String.substring(0, 50) + typeof (base64String));
this.setState({
baa: base64String.substring(0, 200)
})
this.getTextByUrl(base64String)
})
.catch(err => alert(err))
)
})
.catch(err => console.error(err));
}
以仅提取真正共享的块:
minChunks: 2
但是,当我运行构建时,它仍会为仅导入一次的模块生成块(在Webstorm中对optimization: {
splitChunks: {
chunks: 'all',
minSize: 10000,
minChunks: 2, // doesn't work as expected
maxAsyncRequests: 50,
maxInitialRequests: 30,
name (module) {
return (typeof module.resource === 'string') ? 'commonChunk.' + path.basename(module.resource.split('?')[0], path.extname(module.resource.split('?')[0])) : 'commonChunk';
},
},
},
进行的全局搜索仅返回一个正在导入的文件)。是Webpack的错误,还是我误解了这个import [moduleName]
选项?