流星需要Gulp还是Grunt

流星需要Gulp还是Grunt

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

问题描述

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



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

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

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

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



请注意,在[email protected]提供完整的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 [email protected] this may change, though I'm unclear about whether we'll be able to mvoe this into the project yet.

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

08-06 14:22