简体   繁体   English

如果超过特定文件大小限制,如何创建更多的 javascript 块?

[英]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.

相关问题 用户上传的文件超过大小限制后,如何在视图上显示错误? - How to show error on view after file uploaded by user exceeds the size limit? Html视频流大小超过文件大小,如何用javascript缓存和优化html视频元素? - Html video streaming size exceeds the file size , how to cache and optimise html video element with javascript? 如何将数组拆分为给定大小的块? (JavaScript) - How to split array into chunks of given size? (JavaScript) 当数组超过特定大小限制时,node.js会大大减慢速度 - node.js huge slow down when array exceeds a certain size limit 如何将数组分成两半,直到达到一定大小的块? - How to split an array in half until chunks of a certain size are reached? 请求负载大小超过限制:4194304 字节 - Request payload size exceeds the limit: 4194304 bytes Webpack:大小超过推荐限制(244 KiB) - Webpack: size exceeds the recommended limit (244 KiB) 如何通过javascript和php上传文件块 - how to upload chunks of file via javascript and php 如何在 JavaScript 中按块读取本地文件? - How to read a local file by chunks in JavaScript? 如何在 JavaScript 中按块读取本地文件? - How to read a local file by chunks in JavaScript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM