The best way to make your Magento 2 frontend-development workflow wórk as a flow, is to use the included Grunt config. Now that’s quite a pain to set up but I found this article made it possible.
But what if you’ve set this all up, and for some reason Grunt stops watching your files? Here’s a quick rundown of the steps:
- Run developer mode
- Check that all your parent styles are listed in /dev/tools/grunt/configs/themes.js
- run grunt clean
- run grunt exec:THEMENAME
- run grunt less:THEMENAME
- run grunt watch and try again
If it still doesn’t see your changes, run magento setup:di:compile and then the aforementioned steps again.
Running the above commands might give you an error in your console, this has most likely to do with some missing or unwriteable file or folder. In my experience, just clearing your /var/ folder (don’t be afraid, you can delete it without consequence, run rm -rf var), running magento setup:di:compile and then above steps again should fix ’em.
Update: I’ve found that sometimes running above steps still don’t work, but in my particular case the grunt exec:THEMENAME command failed, look closely in the output in your console and you’ll see the error “There are no commands defined in the “dev:source-theme” namespace. Aborted due to warnings.”. I ran the `dev:source-theme:deploy` command and all was well again.