Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 790
dayuloli Avatar asked Dec 20 '14 12:12

dayuloli


People also ask

Which is better Gulp or grunt?

Gulp vs Grunt: Speed The reason for Gulp's current speed advantage is down to the fact that Gulp uses streams and handles tasks in memory, which means that only one file is written. Furthermore, Gulp can process several tasks at the same time, but Grunt will normally only handle one task at a time.

How does Gulp work?

Gulp purely uses the JavaScript code and helps to run front-end tasks and large-scale web applications. It builds system automated tasks like CSS and HTML minification, concatenating library files, and compiling the SASS files. These tasks can be run using Shell or Bash scripts on the command line.

How does installing Gulp globally help?

Gulp comes in two parts: the Gulp CLI (command line utility) that is installed globally on your computer, and then local Gulp packages installed in each individual project you might have. This separation, introduced in Gulp v4 allows you to run different versions of Gulp in each local project.


1 Answers

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.

like image 200
bigmadwolf Avatar answered Oct 01 '22 11:10

bigmadwolf