I am using a theme that I have created based on a third party theme 'Optimus' and I am trying to use Grunt to compile the LESS.
However, when I run grunt less:theme it fails with the following error:
>> NameError: variable @media-common is undefined in pub/static/frontend/vendor/theme/en_GB/css/source/_optimus-lib.less on line 6, column 9:
>> 5
>> 6 & when (@media-common = true) {
>> 7
Warning: Error compiling pub/static/frontend/vendor/theme/en_GB/css/_optimus.less Use --force to continue.
Aborted due to warnings.
Grunt works perfectly on the ultimate parent theme (magento/blank) but it also fails with the same error on the Optimus theme.
Clearly it isn't finding @media-common but searching around this seems to be a Magento variable that defines the type of device (mobile or desktop).
UPDATE:
I think I have resolved this but I would appreciate any feedback to confirm that this is the right thing to do.
I read this post on StackExchange which suggested adding this code:
@import (reference) "../source/lib/variables/_responsive.less";
@import (reference) "../source/lib/_responsive.less";
(I think my file structure is the same as in the post)
Having done this grunt less:theme seems to work but I want to be sure this is correct.