magento2: Grunt watch - doesn't see file changes
[QUESTION] I have node installed and have run ‘npm install’ but when trying to use grunt watch doesn’t pick up on any of the changes i’m making.
I can successfully run ‘grunt refresh’ to recompile but watch does nothing.
it runs without error or warning and sites at a prompt:
Running "watch" task Waiting...
If i then make a change in the less files e.g. app/design/frontend/Magento/luma/Magento_LayeredNavigation/web/css/source/_module.less (simply trying to change option title color)
No change is recognised and no recompile occurs. I’m running under OS X if that has any influence.
What am I missing (or not understanding)?
ALSO:
according to http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/css-topics/css_debug.html
“grunt exec:<theme>
Republishes symlinks to the source files to the pub/static/frontend/<Vendor>/<theme>/<locale> directory.”
All of my files are in pub/static/frontend/… as copies not as symlinks (is this wrong)
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 59 (14 by maintainers)
This is still not fixed. Grunt watch does not work on 2.1.0. Actually, I’d call it completely an utterly broken. Front end workflow is next to impossible with it in this state.
After some more research i managed to fix the watch problem. The problem was caused by the
@importstatement in my less files. I solved changing every import into a:@import '_myfile.less'-> with single quotes, underscore and .less extension.I got it working by running these commands once before running
grunt watch.After that watch works as expected.
Magento comes with “revolutionary” idea: it replaces files from ancestor
sourcewith files from successorsource. This is the most ridiculous design of inheritance I’ve ever seen.Magento developers has to dance around ancestor source files and replace them with successor source symlinks on the fly. This is the only one solution to fix grunt watcher in current funny “inheritance” “design”.
grunt exec:<theme>is not a solution.BTW
grunt exec:<theme>is completely broken. It can create symlink or it can copy file.For some reason symlinking does not work when you start the file with
@importstatements.When I comment out the below lines the symlinks are created and grunt watch works.
@markdavies, Yes, it isn’t fixed. I hate “magento” too. We can add workaround. For example:
I’ve found a “magento certification exam” https://u.magento.com/certification. I am laughing and I can’t stop. xDD
Noone passed a “certification exam”, because development is impossible. xDD
Making sure that imports had .less worked for me as well.
This is still an issue. I’m on
2.2.4andgrunt execdoes not create symlinks.Edit:
I can confirm that taking out the
@importstatements from alessfile will allow symlinks to be created. @rasmuswikmanI can also confirm that changing the quotation marks from double to single, and appending the
lessextension in an import statement will allow symlinks to be created. @TyrianadAdditionally, I can confirm with absolute certainty that the Magento2 frontend is a fickle, over-engineered, and such a poorly designed POS that it’s effectively the eighth wonder of the world in my opinion. It belongs in Reddit’s /r/DiWHY/, too. It really feels like Magento2 developers took every trendy blog post on design from the last decade and stitched them together into some gross Franken-fetish RealDoll. I feel like I need a degree in WTF to change the color of an anchor tag. Explaining Magento2’s frontend is like Bob Newhart’s comedy skit about tobacco.
I can confirm previous statement of @Tyrianad, changing " to ’ in
@import (reference) 'source/lib/_responsive.less';created a symlink instead of a copy.for me, this solves the problem, 1st I run “grunt refresh” than I run “grunt watch” and everything working fine after that.
Thanks
@iget-master To me your solutions is not working though 😦 I’m having the worst developer experience lol, I want to quit my job ahah
@Fredwak my solution works perfectly fine for me (and many others I know). I think this problem is a documentation problem on the Magento side. After more playing around (and using multiple themes) I settled on doing this once for every new theme before running
grunt watchfor the first time.This should be part of the documentation on how to create a new theme.