Does Meteor need either Gulp or Grunt?

送分小仙女□ 提交于 2019-12-03 04:20:41

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/27580077/does-meteor-need-either-gulp-or-grunt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!