任务跑步者(吞咽,咕噜等)和打击者(Webpack,Browserify)。为什么一起使用? [英] Task Runners (Gulp, Grunt, etc) and Bundlers (Webpack, Browserify). Why use together?

查看:105
本文介绍了任务跑步者(吞咽,咕噜等)和打击者(Webpack,Browserify)。为什么一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对任务运行者和bundler世界有点新鲜感,并且经历了诸如


Grunt,Gulp,Webpack,Browserify


,我觉得他们之间没有太大的区别。换句话说,我觉得Webpack可以完成任务跑步者所做的一切。但是我仍然有一个巨大的例子,其中gulp和webpack一起使用。我无法弄清楚为什么。



刚接触这个时,我可能会把事情弄错了方向。如果你能指出我缺少的东西,那将是非常棒的。任何有用的链接,欢迎。



在此先感谢。

Grunt Gulp 实际上是任务运行人员,并且他们有不同的配置驱动任务与基于流的转换。每个人都有自己的长处和短处,但在一天结束时,他们几乎可以帮助您创建可以解决更大构建问题的任务。大多数情况下,它们与应用程序的实际运行时间无关,而是它们转换或者将文件,配置和其他事物放置到位,以便运行时间按预期运行。有时他们甚至会产生服务器或其他您需要运行您的应用程序的进程。



Webpack Browserify 是包裹打包商。基本上,它们被设计为运行一个包的所有依赖关系,并将它们的源代码连接成一个文件(理想情况下)可以在浏览器中使用。它们对于现代Web开发非常重要,因为我们使用了许多旨在使用 Node.js v8 编译器。再次,有些优点和缺点,以及一些开发人员喜欢一种或另一种(或有时两种)的不同原因。通常,这些解决方案的输出包含有某种引导机制,可帮助您获取可能包含大量文件的正确文件或模块。

跑步者和打包者之间的模糊界线可能是打包者也可以做复杂的转换或转换,因此他们可以做几件跑步者可以做的事情。事实上,在browserify和webpack之间,可能会有大约一百个变形金刚,您可以使用它修改你的源代码。相比之下,目前在 npm 上列出了至少2000个一揽子插件。所以你可以看到有明确的(希望是......))定义什么对您的应用程序最适合。



这就是说,您可能会看到一个复杂的项目实际上同时或同时使用任务运行者和软件包捆绑器。例如在我的办公室,我们使用gulp来启动我们的项目,而webpack实际上是从一个特定的gulp任务运行的,这个任务创建了我们在浏览器中运行我们的应用程序所需的源代码包。因为我们的应用程序是同构,我们也捆绑一些服务器代码。



在我看来,你可能想要熟悉所有这些技术,因为你有机会在职业生涯中看到(使用)所有这些技术。


I am a bit new to the task runner and bundler world and while going through things like

Grunt, Gulp, Webpack, Browserify

, I did not feel that there is much difference between them. In other words, I feel Webpack can do everything that a task runner does. But still I got a huge examples where gulp and webpack are used together. I couldn't figure out the reason why.

Being new to this, I might be taking things in the wrong direction. It will be great if you could point out what I am missing. Any useful links are welcome.

Thanks in advance.

解决方案

Grunt and Gulp are actually task runners, and they have differences like config driven tasks versus stream based transformations. Each has its own strengths and weaknesses, but at the end of the day, they pretty much help you create tasks that can be run to solve a larger build problem. Most of the time, they have nothing to do with the actual run-time of the app, but rather they transform or they put files, configs and other things in place so that the run time works as expected. Sometimes they even spawn servers or other processes that you need to run your app.

Webpack and Browserify are package bundlers. Basically, they are designed to run through all of a package's dependencies and concatenate their source into one file that (ideally) can be used in a browser. They are important to modern web development, because we use so many libraries that are designed to run with Node.js and the v8 compiler. Again, there are pros and cons and different reasons some developers prefer one or the other (or sometimes both!). Usually the output bundles of these solutions contain some sort of bootstrapping mechanisms to help you get to the right file or module in a potentially huge bundle.

The blurred line between runners and bundlers might be that bundlers can also do complex transformations or trans-pilations during their run-time, so they can do several things that task runners can do. In fact, between browserify and webpack there's probably around a hundred transformers that you can use to modify your source code. For comparison, there's at least 2000 gulp plugins listed on npm right now. So you can see that there are clear (hopefully... ;)) definitions of what works best for your application.

That being said, you might see a complex project actually using both task-runners and package bundlers at the same time or in tandem. For example at my office, we use gulp to start our project, and webpack is actually run from a specific gulp task that creates the source bundles that we need to run our app in the browser. And because our app is isomorphic, we also bundle some of the server code.

In my humble opinion, you might want to get familiar with all of these technologies because chances are you will see (use) all them in the course of your career.

这篇关于任务跑步者(吞咽,咕噜等)和打击者(Webpack,Browserify)。为什么一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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