How to Regenerate CSS File in pub/static Folder in Magento 2

How to Regenerate CSS File in pub/static Folder in Magento 2

Made a CSS change into the files of your theme?

Not able to see those changes in the pub/static folder?

Not being rendered on the frontend of the Magento 2 store?

No worries, I got your back here.

Read the solution to regenerate CSS file in pub/static folder in Magento 2.

As a store owner, you may want to change the layout or design on the frontend from time to time to keep the content updated according to the latest trend, potential customers’ taste or as your products or services get updated. However, you may have the issue reflecting the changes on the frontend that you implemented from the admin panel.

One of the reasons may be the failure of generating CSS file in pub/static folder in Magento 2.

Hence, you will have to regenerate CSS file in pub/static folder in Magento 2 to offer the new or updated content in the storefront to the customers.

Here’s how you can do it:

The solution to regenerate CSS file in pub/static folder in Magento 2:

Run the following commands to re-generate CSS, JS files, etc.

  1. php bin/magento setup:upgrade
  2. php bin/magento setup:static-content:deploy -f for Magento 2.2.x and Magento 2.3.x.

    If you are using Magento 2.1.x, use php bin/magento setup:static-content:deploy

  3. If you face permission issue, give 777 permission to pub/static generated var folders for Magento 2.2.x and Magento 2.3.x.

    For Magento 2.1.x, give permission 777 to var/view_preprocessed var/cache var/page_cache var/tmp var/generation pub/static

Note: You have to specify locale in php bin/magento setup:static-content:deploy.
e.g php bin/magento setup:static-content:deploy -f hi_IN for Hindi (India)

That was all.

If you still have any doubts, do not hesitate to mention them in the Comments section below. I’d be happy to help.

Feel free to share the solution on social media with fellow developers 😊

Thanks.

 

5
(based on 6 Reviews)

Sanjay is a co-founder at Meetanshi. He is a certified Magento developer who loves creating Magento E-commerce solutions. When he is not engrossed with anything related to Magento, he loves to play cricket.

Leave a Reply