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

查看:14
本文介绍了我应该使用 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,添加一个新的 bundle 只是意味着在配置的入口文件行中有一个额外的入口文件行.这是一个快速指南:https://github.com/petehunt/webpack-howto#7-多入口点.在延迟加载的情况下,您甚至不需要更改配置文件中的任何内容,这很棒 - 只需使用此处详述的异步 require 语法:https://github.com/petehunt/webpack-howto#9-async-loading

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天全站免登陆