Its possible to run grunt tasks within WebStorm through external tools. However, is it possible to avail debugging with external tools? By running tasks like grunt server
or grunt test
within WebStorm, it would make debugging a lot easier if it's possible with external tools like grunt.
-
Check this small article -- use any online translator if required: habrahabr.ru/post/170441 – LazyOne Jun 12 '13 at 10:18
-
1The mentioned article refers to this WebStorm help file: jetbrains.com/webstorm/webhelp/…. – Kees de Kooter Jun 20 '13 at 20:01
Add a comment
|
You have to run grunt-cli as a Node application:
- Create a new Node.js Run/Debug configuration: Run->Edit configurations...
- In Path to Node choose your node binary, ie:
/Users/someuser/nvm/v0.10.5/bin/node
- In Working Directory, choose your
Gruntfile.js
directory, ie/Projects/someproject
- In Path to Node App JS File, choose your Grunt CLI path (you can choose the
grunt-cli
symlink created on your node bin directory, WebStorm will use the symlink target), ie:/Users/someuser/nvm/v0.10.5/lib/node_modules/grunt-cli/bin/grunt
(C:\Users\someuser\AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt
on Windows 7) - In Application parameters enter the Grunt task to run, eg
default
ortest
Click on Run or Debug and you are done :)
-
1Is there a way to config webstorm to run Grunt Test automatically when file is saved? Thanks – Lance Jul 3 '13 at 17:43
-
1I never did it before, but probably if you go to Project Settings and configure a custom file watch (look for "File Watchers" then click on the plus button at the bottom and choose custom), you can launch node with Grunt each time that a file changes. (I usually use grunt watch in a second terminal instead of using File Watchers) – Diego Jul 3 '13 at 20:09
-
Any ideas why starting a debug session for this takes a lot of time to start up? – devmiles.com Sep 8 '13 at 21:59
-
I think that ItelliJ guys are the best to answer that question (you can create a ticket here: youtrack.jetbrains.com/issues). But my bet is that when NodeJS starts in debug mode, probably some V8 optimizations are off, so maybe loading all the dependencies of Grunt with debug support takes more time. Another possible cause could be some network config in your machine (NodeJS debugger uses TCP to expose the debug interface, that's used by WS). But again... my "answers" are just guesses :) – Diego Sep 14 '13 at 5:12
-
8For me, I used the output of
which grunt
to find the correct Path to Node App JS File – JonnyReeves Dec 11 '13 at 20:18
I just happened to try this in WebStorm 10 today. I'm not sure if it's a new feature but WebStorm have integrated the steps described by @diego so you don't have to perform them manually:
- Click View > Tool Windows > Grunt to display the Grunt window in WebStorm.
- Right-click on any task and choose "Debug"
You can set breakpoints etc. in Gruntfile.js
just like you would any other file.
-
You have to make sure you include any env vars that you have in the run configs because you lose these when going via the Tool Windows via the
Edit 'task' settings...
option when right-clicking – br3w5 Mar 22 '19 at 14:39