javascript - webpack packaging, dependency loading
PHP中文网
PHP中文网 2017-05-19 10:26:12
0
4
495

Ask the master, webpack usually outputs a complete js file. How can the generated js module be loaded dependently?

PHP中文网
PHP中文网

认证0级讲师

reply all(4)
仅有的幸福

Entry sets multiple entry files and packages them into multiple
require.ensure to separate modules that need to be loaded asynchronously on demand

刘奇

If you’re not sure if you understand it correctly, you can refer to it.
First of all, webpack packaging can package js into independent files, so who is still not together.
Secondly, load some js modules by using asynchronous loading in main.js.
At this time, you will usually get two or more js files after packaging. One is required for the homepage, and the other js is loaded when it is loaded into the corresponding module or page.
Hope this helps

phpcn_u1582
  • If you use the latest Webpack2, the specification document recommends using import 替换过时的 require.ensure.

  • Officially also recommended to usebundle-loader

I didn’t test the first one successfully, but the second one works.

为情所困

There are multiple entrances in the entry, I will show you the screenshot and you will understand

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!