I'm trying to configure Grunt in PhpStorm.
I have set for Grunt: Node interpreter: /usr/bin/node (exists) Package grunt-cli: [path to Magento 2 dir]
I get the error bellow when I 'Reload tasks' in PhpStorm.
grunt-cli is installed in the project. I have a [path to Magento 2]/node_modules/ dir. And grunt clean:[my theme], exec and watch work in console.
I'm aiming to have PhpStorm run grunt watch and refresh the page in browser.
EDIT Settings that worked with Grunt are:
- Node interpreter:
- Package grunt-cli:
and clicked 'Reload Tasks' icon
Assuming one configured the project as in:
and has configured also the store them in
Add a File Watcher in Settings > Tools > File Watchers as explained here: http://www.kevinfodness.com/automating-grunt-builds-in-phpstorm with a few differences:
- 'File Type': Less
- In 'Scope' there should be the directory of your theme from vendors/[my namespace]/[my theme dir] because we suppose to change files here. I have added a few more dirs from vendors/[my namespace]/[my modules that have less]
- In 'Scope' you don't need to Exclude .css files because these are in pub/static and not in vendors/my_namespace/my_theme dir.
- 'Program': grunt (my dev machine sees this command globally)
- I could have in 'Arguments' this instead:
clean:my_theme exec:my_theme less:my_themebut not sure if I want to.
less:my_themetakes already 5 secs to run. You can run clean and exec in console if you need it.
- 'Outputs path to refresh': I've cleaned it. Nothing here instead of the default field value.
I have set up the watcher and it works. But now I'm thinking why not just use
grunt watch in console.
Next step is to find out how PhpStorm can refresh a browser window after it completes the watcher's task. This is why I want to have Grunt in PhpStorm. I don't want to alt+tab in console to see if
grunt watch finished the task and than alt+tab to refresh a browser window.