6

I'm using Ubuntu with Magento 2.2 installed locally for development.

I'm updating my LESS, but it's just not compiling for some reason.

I have all caching turned off in Cache Management, and I run magento setup:static-content:deploy -f after any LESS modifications, but it's still not compiling and showing my changes. I just changed a css padding value from 10 to 11 to test, and it's still set to 10.

I also have caching turned off in my browser, too. And I've ran rm -rf var/view_processed then static content deploy, but that didn't work either.

Also, My Workflow Type is set to Server side less compilation, and the local install of Magento 2 is set to Developer Mode.

So I'm at a loss for what to do to get my LESS to compile into CSS. It's just not doing it for some reason.

Any ideas?

Thank you.

2 Answers 2

7

Did you delete the compiled file in the pub/static folder first? You should delete those css files (the styles-m.css and the styles-l.css), clear the var/view_preprocessed folder and then run compile.

In some cases, the files in the pub will create sym links to the source file. When that is a the case, you don't have to delete it first, so check the pub folder to see the state of those files (this is a setting in the app/etc/di.xml but it a whole other question to configure this).

If nothing is working after that, you should check the file you are working on itself. You should be editing the:

app/design/frontend/{vendor_namespace}/{theme}/web/css/source/_extend.less

And then if nothing is working check the file permission for the pub and var folders. While working in development, i run these folder with open permission sudo chmod -R 777 pub/ var/. But note that when you push live, if you are moving these directories directly, these permission might be too open (i push code with git so i don't have to worry about generated file and directories).

4
  • 1
    Isn't that what magento setup:static-content:deploy -f is supposed to do? Clear out that pub/static stuff? Or am I wrong?
    – James
    Feb 9, 2018 at 16:29
  • As far as i have tested, Magento doesn't clear any file with that command. Those commands are hard to understand since the M2 implementation is a bit convoluted, but when you deploy, if the file is there in the pub folder, compile will skip that file all together.
    – circlesix
    Feb 9, 2018 at 16:40
  • 2
    Gotcha. Using the info you gave me, this command worked: rm magento2/pub/static/frontend/vendor/default/en_US/css/styles-m.css && rm magento2/pub/static/frontend/vendor/default/en_US/css/styles-l.css && rm -rf var/view_processed && magento setup:static-content:deploy -f thank you!
    – James
    Feb 9, 2018 at 16:45
  • sweet! setting up grunt will help you out a lot here. there are some good sources around, but till then, glad this works for ya.
    – circlesix
    Feb 9, 2018 at 16:55
6

This should work:

rm -rf var/view_preprocessed
rm -rf pub/static/frontend

You don't have to run setup:static-content:deploy if you are in developer mode.

It's possible that the user created the files in pub/static was different than your webserver user, so the webserver user can't change them.

1
  • Work by removing the content but takes too much time in loading after that.
    – AbdulBasit
    Jan 17, 2021 at 18:42

Your Answer

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

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