2

I have recently added a new root source css file for magento storefront by putting it in default_head_blocks.xml throught below statement.

<css src="css/custom.css"/>

Now I ran upgrade command

php bin/magento setup:upgrade

I am having the same custom.less file at below path of my custom theme.

app/design/frontend/myvendor/mytheme/web/css/custom.less

When I now try to run deploy command Magento is giving me an error

pub/static/frontend/myvendor/mytheme/en_US/css/custom.css): failed to open stream: No such file or directory

I don't know if this is a version issue or not but I already tried signing off static files from backend by setting

store>configuration>advanced>Developer>Static File Setting>Sign Static Files to No

as well as trying to run the command again with admin rights.

Still, the error persists.

  • did you create custom.css file also at the location of pp/design/frontend/myvendor/mytheme/web/css ? – Ansar Husain Sep 19 '18 at 5:55
  • read this block for batter understanding how less css work in M2 webkul.com/blog/use-less-magento-2-template-modules – Ansar Husain Sep 19 '18 at 6:27
  • Yes, I have created .less file at that location. – Shashank Bhatt Sep 19 '18 at 16:31
  • If I create blank .less file, magento is giving an error. Is it normal behavior of static content deploy? – Shashank Bhatt Sep 19 '18 at 16:34
1

This error was actually created as custom.less file was blank and therefore magento was not generating custom.css file from it.

I don't know if it is bug or not as blank custom.css file should be generated from respective blank custom.less file.

Adding some css rules to it solves this issue.

  • Could you please explain more about this. what kind of css rules are required ? – chanchal May 1 at 4:46
  • Add any css selector with properties in it. In short, file should not be blank. – Shashank Bhatt May 1 at 4:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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