简体   繁体   English

如何使用Webpack在一个min.js文件之后调用特定的min.js文件?

[英]How to call a particular min.js file after one min.js file using webpack?

I have 2 min.js files and I want to call a particular file that populates the store (redux-store) initially and then I want to render the contents of the second file that will be using the pre populated store. 我有2个min.js文件,我想调用一个最初填充商店(redux-store)的特定文件,然后想呈现将使用预填充商店的第二个文件的内容。 eg 2 files 'a' and 'b', 'a' contains a string for name in the store now after getting the string from the user display the string using file 'b'. 例如,有2个文件“ a”和“ b”,“ a”现在在商店中包含一个名称字符串,这是从用户获取字符串后使用文件“ b”显示该字符串。

Is it possible to specify 'a' file as entry point in webpack initially and then when an event occurs like onClick etc 'b' file is specified as entry point and it gets executed to produce the b.min.js file that can be used to display? 是否可以最初在Webpack中将“ a”文件指定为入口点,然后在发生事件(如onClick等)时将“ b”文件指定为入口点并执行以生成可以使用的b.min.js文件显示?

Why you want to do that. 为什么要这么做。 Use one file it is faster, request for other file is not as fast as only one request. 使用一个文件速度更快,对其他文件的请求速度不及一个请求。

In your display b file with components you need to require store and reducers and other files to compile the bundle. 在带有组件的display b文件中,您需要使用store和reducers以及其他文件来编译捆绑包。

If you are looking for extracting common packages as React, React Router you can use CommonsChunkPlugin. 如果您希望将常用包提取为React,React Router,则可以使用CommonsChunkPlugin。

If you have complicated initial state in store. 如果您在商店中有复杂的初始状态。 Load it as JSON. 将其加载为JSON。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM