我应该使用Browserify还是Webpack延迟加载angular 1.x中的依赖项 [英] Should I use Browserify or Webpack for lazy loading of dependencies in angular 1.x

查看:76
本文介绍了我应该使用Browserify还是Webpack延迟加载angular 1.x中的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在大型应用程序中异步加载角度相关性,并且我试图在 Browserify 之间进行选择或 Webpack .我知道angular 2.0将在本机支持此功能,但现在我正在寻找一种受良好支持的流行解决方案.

I would like to have async loading of angular dependencies in a large application and I'm trying to decide between Browserify or Webpack for this. I know angular 2.0 will support this natively but for now I'm looking for a well supported and popular solution.

任何人都可以提出建议,以帮助哪些人在角度小组中最有效,以及构造项目的最佳方式.

Can anyone give advice on which ones works best in an angular team and the most optimal way to structure the project.

推荐答案

在我公司,出于多种原因,我们已经从browserify切换到了webpack,其中之一就是延迟加载.

At my company, we've switched over from browserify to webpack for a multitude of reasons, lazy loading being one of them.

在browserify中将其放入多个包中需要进行一些配置更改以及特殊代码.这是有关 http://esa- matti.suuronen.org/blog/2013/04/15/asynchronous-module-loading-with-browserify/

Putting things in multiple bundles in browserify took some configuration changes as well as special code. Here is a great guide for that http://esa-matti.suuronen.org/blog/2013/04/15/asynchronous-module-loading-with-browserify/

对于webpack,添加新的包仅意味着在配置的条目文件行中有一个额外的条目文件行.这是有关此的快速指南: https://github.com/petehunt/webpack-howto#7-多个入口点.在延迟加载的情况下,您甚至不需要更改配置文件中的任何内容,这非常了不起-只需使用此处详细介绍的异步require语法即可:

With webpack, adding a new bundle just means an extra entry file line in the configuration's entry file line. Here is a quick guide to that: https://github.com/petehunt/webpack-howto#7-multiple-entrypoints. In the case of lazy-loading, you don't even need to change anything in the configuration file, which is awesome - just use the asynchronous require syntax detailed here: https://github.com/petehunt/webpack-howto#9-async-loading

这里是设置模板,与我们在生产中 https://bench.co 使用的模板非常相似. https://github.com/jeffling/angular-webpack-example/

Here is a template for a setup very similar to what we use at https://bench.co in production. https://github.com/jeffling/angular-webpack-example/

这篇关于我应该使用Browserify还是Webpack延迟加载angular 1.x中的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆