[英]How to create further chunks of javascript if it exceeds certain file size limit?
Is there any way that I can automate further chunking of javascript file if it exceeds from a defined file size limit.如果 javascript 文件超出定义的文件大小限制,有什么方法可以自动对其进行进一步分块。
To explain the problem further.进一步说明问题。 Lets just say I have different modules "product landing page(plp)" & "product detail page(pdp)".
假设我有不同的模块“产品登陆页面(plp)”和“产品详细信息页面(pdp)”。 Both has different JS files already ("plp.js
60kb
" and "pdp.js 55kb
" accordingly).双方已经有不同的JS文件( “plp.js
60kb
”和“pdp.js 55kb
”相应)。
* How can the files be chunkified further if it exceed from certain file size limit? * 如果文件超出特定文件大小限制,如何进一步分块文件? *
*
So the expected output when the limit is set as 50kb
should be...所以当限制设置为
50kb
时的预期输出应该是......
plp-1.js `50kb`
plp-2.js `10kb~`
pdp-1.js `50kb`
pdp-2.js` `5kb~`
You can specify entry points in you webpack.config.js
file:您可以在
webpack.config.js
文件中指定入口点:
entry: {
index: './src/index.js',
another: './src/another-module.js',
},
It will create a new chunk output:它将创建一个新的块输出:
Asset Size Chunks Chunk Names
another.bundle.js 550 KiB another [emitted] another
index.bundle.js 550 KiB index [emitted] index
Entrypoint index = index.bundle.js
Entrypoint another = another.bundle.js
See docs here: https://webpack.js.org/guides/code-splitting/请参阅此处的文档: https : //webpack.js.org/guides/code-splitting/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.