running static-content:deploy on multi store-view, fails with following error variable @media-common is undefined on theme where the language en_US

  • have you working on developermode or production mode? – Rakesh Jesadiya May 2 '16 at 13:11
  • locally on development – deroccha May 2 '16 at 13:12
  • have you set client side development inside store configuration? – Rakesh Jesadiya May 2 '16 at 13:15
  • Go to that file and on that line number change @media-common to @_media-common – Asish Hira May 2 '16 at 13:15
  • @Asish Hira 5 hm interesting @_media-common seems to work can u explain why? – deroccha May 2 '16 at 13:20

@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.

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 Jan 5 '17 at 14:08

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

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.