magento2: LESS doesn't compile to CSS in production mode

Preconditions

  1. Magento 2.1 in production mode
  2. Varnish

Steps to reproduce

  1. Make changes to _extend.less
  2. Run php bin/magento setup:static-content:deploy fi_FI en_US

Expected result

  1. LESS changes applied to CSS

Actual result

  1. LESS code in custom template is compiled to global LESS but not to CSS

The only workaround I’ve found is to set Magento into developer mode and then back to production mode.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 7
  • Comments: 28 (11 by maintainers)

Commits related to this issue

Most upvoted comments

The issue should be re-checked on the latest 2.4-develop branch. If its still actual on 2.4-develop it should be confirmed with the label Reproduced on: 2.4.x Description and versions should be updated If not the issue should be closed

Hello Team,

I am also facing same issue when i follow the below scenario

Magento 2 version is: 2.2.3 CE Mode:- Production Css/Js :- if the files are in merged from developer mode

File/path from theme :- app/design/frontend/Custom/demo/web/css/custom.less

Server:- AmazonCloud (magemojo) Result:- These custom.less files changes are not effecting/updating in the respected custom.css in the pub folder.

Again if i switched to developer i am able to see the changes.

Can you provide your thoughts on this.

Thanks

Really curious what causes this issue.

In every (!) installation of mine I’m able to regenerate LESS the following way in developer mode:

$ php bin/magento deploy:mode:set developer
$ php bin/magento setup:upgrade

as intial step. After that, all I have to do is:

$ rm -rf var/cache/* var/page_cache/* var/view_preprocessed/* pub/static/*

That said, I have disabled just a few caches to speed up developing to its most efficiency in my cases, but maybe here is the magic? If you disable

  • page cache
  • config

does it work for you with this pattern?

However - you still have Varnish in front. So maybe you just need to flush the cache of varnish or disable it for sorting out the problem. If the right CSS is shown in frontend with Varnish disabled, the problem is varnish - you should try the magento CLI functions of flushing caches, it should clear the cache (by semantic I’d guess) and also clear varnish.

Would love to get some feedback from you as I believe this bug is maybe due to some weird configurations. But just my 2 cents.

Have you tried to clear the view_preprocessed folder with $ rm -rf /var/view_preprocessed? Alternatively you could clear CSS/JS Cache in Backend. Maybe this works for you.