1

My website is working just fine on Developer mode, whenever I try to switch to Production my website is not loading js or icons/images. I am attaching an image so you can see the errors in chrome devtools. In addition I am following the guideline from here: Set the Magento mode I have not deleted the .htaccess file. I've tried to follow this Magento 2 issues with no success again.

Error logs

temper
  • 994
  • 11
  • 44
h3k
  • 171
  • 1
  • 3
  • 12
  • Have you got the message that static content was successfully deployed after switching to production mode? Try running bin/magento setup:static-content:deploy – Sergii Ivashchenko Nov 17 '19 at 21:09

2 Answers2

1

In Magento 2, You do not need to run static:content:deploy command every time when your Magento mode is default or developer, but when you change Magento mode to production at that time Magento will not generate static content file automatically.

So you need to run deploy commands in this sequence..

You can change your Magento mode from developer to production using below command.

php bin/magento deploy:mode:set production --skip-compilation

After running above command your Magento mode will be change from developer to production, then you need to run below commands.

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento setup:static-content:deploy -f en_US bg_BG

Here I've used bg_BG in setup:static-content:deploy command that is your locale which you have set for Bulgarian country. If you will run only this command php bin/magento setup:static-content:deploy -f at that time you can see Magento will generate files under en_US locale by default in following directory.

pub/static/frontend/Vendor/Theme/en_US/

And your locale is bg_BG so you need to generate files for that locale. So you need to run below command

php bin/magento setup:static-content:deploy -f en_US bg_BG

When you run above command at that time Magento will generate files under en_US and bg_BG as well.

pub/static/frontend/Vendor/Theme/en_US/

pub/static/frontend/Vendor/Theme/bg_BG/

Hope this information helps you!

Kishan Savaliya
  • 7,736
  • 1
  • 12
  • 27
0

Please follow any of below Solutions:

1) Your issue will solved by running below command, if not then follow below mentioned steps:

php bin/magento setup:static-content:deploy -f en_US be_Bg

2) when you switch dev to production mode, remove cache, generated and pub/static.

3) Run Below mentioned commands:

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f en_US be_Bg
php bin/magento cache:flush

Hope any of above solution will help.

temper
  • 994
  • 11
  • 44