node.jsmeteorgruntjsgulpisobuild

Does Meteor need either Gulp or Grunt?


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?


Solution

  • 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.

    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.