News for hackers. Stuff that matters.
Re:Grunt.js: Tips and Tricks by Kiro on Tuesday January 21, 2014 @12:30PM (#7096741)
Can someone please tell me what exactly they are using Grunt for? I just don't see what problem it solves.
Re:Grunt.js: Tips and Tricks by tieTYT on Tuesday January 21, 2014 @02:16PM (#7097550)
I wish you would have elaborated on your question because it seems pretty obvious to me and I'm not sure what your experience level is (or what language you're using). Or maybe you're thinking, "I don't get the point of Grunt, isn't X better?" I can't tell.

Grunt is to JavaScript as Ant is to Java. "The main usage of Ant is to build Java applications." So, "The main usage of Grunt is to build JavaScript applications".

I'm making a game and I use it for many different tasks:

1. Every time a coffeescript file changes, compile that file to javascript

2. Every time a js file is added or deleted, change the list of script tags in the html file

3. Every time a sass file changes, run compass to compile it into a css file

4. I've got a test suite (qunit, it runs off an html file) that uses the same script list that my main game uses (and more). I've turned the script list into a variable so I don't have to modify either html file by hand if I add/remove a coffeescript file.

5. Every time a js file changes, is added or deleted, run unit tests in the background using phantomjs

6. If a unit test fails, beep 3 times

7. Every time a coffescript file changes, is added or deleted, reload the page so I can see my change. This is configurable so I can turn this feature off.

8. When I build for production, concatenate all the files and minify them.

9. Every time any file changes, update the html file to have a new build-time variable.

I would be super unproductive if I had to do these tasks by hand. Grunt.js lets me automate these tasks and reuse them as many times as I want. For example, I used to run my qunit tests by hand by going to the .html file and refreshing the browser. But sometimes I forgot or I didn't want to lose my train of thought. Sometimes this would lead to me accidentally committing broken code. That's why I automated the tests to run in the background whenever a file changes. Now I can't forget to run the unit tests and I don't have to lose my train of thought.

Re:Grunt.js: Tips and Tricks by bichiliad on Tuesday January 21, 2014 @12:39PM (#7096806)
I'm using it to automate testing/concatenating/minifying a front-end library I'm working on.
Re:Grunt.js: Tips and Tricks by dougbarrett on Tuesday January 21, 2014 @01:44PM (#7097276)
I do the same with a PHP project, it's nice because I just don't include the original JS source files when I push to staging/production
Re:Grunt.js: Tips and Tricks by AlexMcP on Tuesday January 21, 2014 @12:54PM (#7096930)
I use it outside of a Rails project when I don't have the asset pipeline available in my tool chain. It gives me the scalpel to define exactly what happens to my code and files vs. a one-size-fits-all option like LiveReload or Brunch where I need to match a specific filesystem layout.
Re:Grunt.js: Tips and Tricks by mikewhy on Tuesday January 21, 2014 @01:23PM (#7097142)
Should be noted that paths in brunch aren't set in stone. app/ gets some special treatment is all. For instance our current project has app.js, vendor.js, test.js, test-vendor.js, admin.js, admin-vendor.js
Re:Grunt.js: Tips and Tricks by donut2d on Tuesday January 21, 2014 @12:36PM (#7096786)
I'm using it to automatically watch for changes to CoffeeScript and SASS files and then run the appropriate preprocessor when they change and tell my browser to refresh via LiveReload.
Re:Grunt.js: Tips and Tricks by mikewhy on Tuesday January 21, 2014 @12:46PM (#7096862)
brunch does all this, without the need for a ~100 line config file.
Re:Grunt.js: Tips and Tricks by tieTYT on Tuesday January 21, 2014 @02:23PM (#7097598)
mikewhy: see my large post. Can brunch do all of that? I have no idea what brunch is and it's hard to google. What language is it for? Ruby?