running static-content:deploy on multi store-view, fails with following error variable @media-common is undefined on theme where the language en_US
3 Answers 3
@deroccha, I have laid out an answer to this question over here https://magento.stackexchange.com/a/152944/1956.
The long and short of it, is that @media-common isn't within the scope of your theme, in one or more .less files. We're supposed to be able to control this via use of _extend.less (which would load our custom files after var/view_preprocessed/css/frontend/<Vendor>/<theme>/<locale>/css/source/lib/_responsive.less, but for some reason that doesn't always seem to work. That being the case, you can follow the instructions in the above link as a temporary solution.
UPDATE The use of _extend.less does work as long as there isn't another configuration somewhere, like adding an implicit css call on a page configuration xml file. An example implicit css call:
<head>
<css src="css/custom/theme.css" />
</head>
If there is this type of entry, then there shouldn't also be an @import in the theme's _extend.less ...either or should be used.
-
Can you answer this question, please? -> magento.stackexchange.com/questions/290595/…Kowsigan Atsayam– Kowsigan Atsayam2019年09月23日 14:55:32 +00:00Commented Sep 23, 2019 at 14:55
In my case the issue was caused by first letter in my custom styles file name. File name should start from underscore, it provides proper files merging queue. For instance,file with name product.less
app/design/frontend/Vendor/theme/web/css/source/theme/product.less
caused error during static content deploy @media-common is undefined. Adding the underscore at the beginning of name resolved issue.
app/design/frontend/Vendor/theme/web/css/source/theme/_product.less
-
Thank you! I have the same problem all day and I thought I'd lose my mind because everything was correct. Adding an undercore to my custom less file names solved the issue!disappointed.moose– disappointed.moose2020年05月28日 12:24:39 +00:00Commented May 28, 2020 at 12:24
We found that deploying Magento 2 causes so much problems we just run in developer mode on the production site. Not a pretty solution but at least we can actually put sites live without a hundred errors.
Until the errors and the process is resolved by the core team we'll be using this solution. The github issue is more than a year old now. There is not even an official guide for deployment:
http://devdocs.magento.com/guides/v2.1/config-guide/prod/prod_deploy.html
-
Running in developer mode vs production mode doesn't solve the issue of the @media-common variable not being within the scope of Less files being transpiled. I do feel your pain though.ryanF– ryanF2017年01月05日 14:08:05 +00:00Commented Jan 5, 2017 at 14:08
Explore related questions
See similar questions with these tags.
@media-commonto@_media-common@_media-commonseems to work can u explain why?