流星需要Gulp还是Grunt? [英] Does Meteor need either Gulp or Grunt?

查看:97
本文介绍了流星需要Gulp还是Grunt?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我一直在阅读有关 Gulp Grunt ,以及它们如何缩小代码,压缩文件,将文件合并为一个,livereload等。然而, Meteor 已经完成了所有的工作,使用 Isobuild



我问的原因是有人建议使用Gulp和Meteor,而我并不认为需要它。为什么我应该将Gulp和Meteor一起运行,有哪些可能的原因?或者它只是多余的?



如果不是多余的,Gulp有什么功能不在Isobuild中? Meteor团队计划将Gulp整合到其下一个版本中吗?

解决方案

需要可能不是合适的词。正如上面提到的评论,Meteor包含一个非常聪明的自己构建的系统isobuild,它构建了你的整体应用程序为你。但是,当然有些情况下你可能需要你自己的任务,最好通过咕噜或咕嘟咕嘟地完成。 (你可以用这些完成的任务的范围是惊人的,所以我只列出几个简单的常见例子。)

最明显的将会是您想要放入公用文件夹的资产。但是,这远远不是你可能希望在一个更大的项目中自动执行的任务的详尽清单。




  • 编译不使用libsass的SASS文件编译器(因为它不支持所有功能)

  • 压缩和优化图像,svg文件,网站图标等。

  • 创建多种尺寸/版本的图像

  • 创建Sprite表格

  • 以您自己的订单/方式连接并缩小脚本

  • 与Bower一起管理无法通过气氛等获得的前端包。



我的方法是将所有这进入了私人文件夹,所以它避免了由流星isobuild构建系统。



我相信这些足够的理由不考虑Gulp或Grunt冗余,并且任务的范围可能与咕噜声或吞咽变化很大,他们不能全部在这里列出。毋庸置疑,IsoBuild对于它的功能非常棒,但并不能代替这些任务运行者的一切可能,据我所知,没有计划将Gulp整合到IsoBuild中。 IsoBuild是Meteor的核心,gulp和grunt是非常强大的自动化工具,有数以千计的可能用途。

继承人是一个非常好的起跑者,它非常简单开始: NodeJitsu Gulp教程



所以当然,你不需要 grunt或gulp,但是他们当然可以在你的流星项目中有一个富有成效的地方,他们绝对是有价值的工具,可以帮助你精简开发流程。 / p>

如果您想要使用grunt或gulp,这就是我如何处理结构我的项目:

<$ p $项目文件夹
| __ webapp //我的流星应用程序住在这里
| __ assets // scss / images / svgs
| __ node_modules
| gruntfile.js
| .eslintrc
| package.json

然后构建,缩小和处理我的资产,目标目录位于 webapp / public



请注意,在Meteor@1.3提供完整的npm支持后,这可能会改变,尽管我不清楚我们是否可以将此项目融入项目中。

So I've been reading about Gulp and Grunt, and how they can minify code, compress files, combine files into one, livereload etc. However, Meteor does all that already, with Isobuild.

The reason I'm asking is someone suggested using Gulp with Meteor, and I don't see a need for it. What are some possible reasons why I should run Gulp alongside Meteor? Or it is simply redundant?

If it is not redundant, what features does Gulp has that is not in Isobuild? And will the Meteor team plan to incorporate Gulp into its next versions?

解决方案

Need is probably not the right word. Whether you want it or not is a different story.

As the comments mentioned above, Meteor include a very clever build system of its own called isobuild, which builds your WHOLE application for you. But there are certainly instances where you may want your own tasks which would best be accomplished through grunt or gulp. (The range of tasks you can accomplish with these is staggering, so I'm only going to list a couple simple common examples.)

The most obvious is going to be for assets you want to put in your public folder. But this is far from an exhaustive list of tasks that you may want to automate on a larger project.

  • Compile SASS files not using the libsass compiler (because it doesn't support all the features)
  • Compress and optimize images, svg files, favicons, etc.
  • Create multiple sizes / versions of images
  • Create Sprite Sheets
  • Concatenate and minify scripts in your own order / manner
  • Combine with Bower to manage front end packages that aren't available through atmosphere etc.

The way I would approach it is by putting all of this into the private folder, so its avoided by the meteor isobuild build system.

I believe these are enough reasons to not consider Gulp or Grunt redundant, and the range of tasks possible with grunt or gulp are so varied they can't all be listed here. Needless to say IsoBuild is fantastic for what it does, but would not replace everything possible with these task runners, and to my knowledge there are no plans to incorporate Gulp into IsoBuild. IsoBuild is core to what Meteor is, gulp and grunt are very powerful automation tools with thousands of possible uses.

Heres a really great starter for gulp, its super simple to get started with: NodeJitsu Gulp tutorial

So, sure, you don't need grunt or gulp, but they could certainly have a productive place in your meteor project and they're definitely worthwhile tools to get to grips with to streamline your dev processes.

If you would like to use either grunt or gulp, this is how I approach structure my project:

Project-folder
    |__ webapp  // my meteor app lives here
    |__ assets  // scss / images / svgs
    |__ node_modules
    | gruntfile.js
    | .eslintrc
    | package.json

I then build, minify, and process my assets, with my target directories in webapp/public

Note that with full npm support coming in Meteor@1.3 this may change, though I'm unclear about whether we'll be able to mvoe this into the project yet.

这篇关于流星需要Gulp还是Grunt?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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