What are they for?
Simply and simply, both serve to automate and simplify your workflow and processes.
For example, I use Grunt
to process my files in SASS
and generate a CSS
minificado, without having to copy my file, send to an online service to minificar, or worse (and much less likely), do by hand. Another example would be the concatenation of files JS
, send your files to an online hosting through a connection ftp
, etc. There are several options.
Is there any relationship between them?
Yes and no. Yes, because both have the same purpose, automate and simplify processes. Not because the way they are made differ from each other and there the question changes a lot, because it begins to come more into a matter of preference than which is better.
They can be compared to Bower, for example?
Not. Bower
is to be compared with NPM
. Both are package managers, for example, you will use them to download a plugin while grunt
or gulp
will be used for processes (or tasks) within these plugins. Bower
and NPM
would have more purpose for you to download the bootstrap
, for example, check the version and keep up to date, all without having to actually go to the bootstrap
and do it manually.
Would you have some example of how/or when to use one or the other?
As already mentioned in the answers above, but only to reinforce. There are several tasks that they can perform, I will mention the ones that I use most through the Grunt
:
- Concatenate and process
SASS
and Compass
;
- Remove unused classes from a file
CSS
when compared to archives html
;
- Minify the file
CSS
and compress into gzip
;
- Concatenate and minify files
JS
;
- Compress the project and upload to a connection
ftp
, putting the project online;
That is, all this process is executed automatically by Grunt
. I just need to run the command line, example grunt execBuild
(based on my settings and packages) and all these tasks will be performed automatically. So you can see a very practical, functional and highly automated example.
Can you imagine doing it all?
Excellent! Very good response!
– Geferson