7

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

Raphael at Digital Pianism
70.8k37 gold badges192 silver badges357 bronze badges
asked May 2, 2016 at 13:08
7
  • have you working on developermode or production mode? Commented May 2, 2016 at 13:11
  • locally on development Commented May 2, 2016 at 13:12
  • have you set client side development inside store configuration? Commented May 2, 2016 at 13:15
  • Go to that file and on that line number change @media-common to @_media-common Commented May 2, 2016 at 13:15
  • @Asish Hira 5 hm interesting @_media-common seems to work can u explain why? Commented May 2, 2016 at 13:20

3 Answers 3

2

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

answered Jan 3, 2017 at 16:36
1
2

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
answered Jun 28, 2018 at 22:36
1
  • 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! Commented May 28, 2020 at 12:24
0

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

answered Jan 5, 2017 at 14:01
1
  • 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. Commented Jan 5, 2017 at 14:08

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.