24

I was in developer mode, everything was great, when I changed to Production mode, the Merged options of CSS and JS seem to be ignored, it was back listing all css and js.

Also the product page only shows the pictures of the product in developer mode, after changing to production mode they disappear.

Any thought to help me?


The point is, I'm doing it.

Here is what I did in sequence:

bin/magento setup:upgrade

bin/magento indexer:reindex

bin/magento setup:static-content:deploy

bin/magento setup:di:compile

bin/magento deploy:mode:set production

bin/magento setup:static-content:deploy

And before even starting, the Merge options are YES and I was in developer mode.

  • Hello, Have you got any solution of this issue, I am getting same issue in magento 2.0.7. Please give the solution if you have any, Thanks – Ashish Jagnani Oct 3 '16 at 9:36
  • same issue i am facing it please help me – Rv Singh May 30 at 13:31

10 Answers 10

19

I just did the following and the problem was solved:

bin/magento setup:upgrade

bin/magento indexer:reindex

bin/magento deploy:mode:set production -s

# Here was the secret: run the di:compile after production
bin/magento setup:di:compile  

bin/magento setup:static-content:deploy
  • 2
    i tried same way but no luck – Pradeep Kumar May 31 '16 at 8:30
  • This worked for me. – dchayka Jan 10 '17 at 15:55
  • If i execute command "production -s" it blank my site and give very unusal error: Warning: include(/siteRoot/html/var/view_preprocessed/html/vendor/magento/module-theme/view/base/templates/root.phtml): failed to open stream: No such file or directory in /siteRoot/html/vendor/magento/framework/View/Result/Page.php on line 312 – Jai Feb 24 '17 at 9:25
  • Another - that worked for me. In case anyone else is having the problem I was. CSS would minify and bundle, but JS would not, despite having the options enabled in the admin. Adding the -s in the set product mode made all the difference. Also, the backend is MUCH faster now as well. I was using the same order and commands, but it was the "-s" that made the difference, Thank you – dawhoo Mar 26 '17 at 20:31
  • Do i first need to switch back to development mode? I did what you mentioned, but no difference.... – Jilco Tigchelaar Jul 24 '17 at 18:22
2

Make sure you check your NGINX configuration file as well.

If there is a variable $MAGE_MODE set there it needs to be changed to production as well, and save the file

After that you will need to reload or restart NGINX depending on your preference.

sudo service nginx reload

OR

sudo service nginx restart

After that check your app/etc/env.php and see if the MAGE_MODE array key is set to production as well if not change it to production or you can use the command

php bin/magento deploy:mode:set production

After you executed the command check if the value changed app/etc/env.php, sometimes there might be permission issues.

Next, clean out the pub/static folder.

rm -rf pub/static/*

Clear/Flush your cache

php bin/magento cache:clean
php bin/magento cache:flush 

Now you are ready to execute the static content deploy

php bin/magento setup:static-content:deploy

Hope this helps.

1

I have the similar issue. The cause for no image is because there is an error in JS file after minify JS. You can verify it in your browser (firebug etc).

.../div>';return __p};})(window,document,location,typeof jQuery!=='undefined'&&jQu

I solved this by remove all the file in var/cache/ and pub/static/ and setup:static-content:deploy again

But there is still another issue, it's about the braintree if you enable it. Braintree doesn't show up due to another JS error.

Error: Script error for: https://js.braintreegateway.com/v2/braintree.js http://requirejs.org/docs/errors.html#scripterror

...Error(id,msg,err,requireModules){var e=new Error(msg+'\nhttp://requirejs.org/doc...

For now, I simply don't use the minify js function to avoid the trouble until solution is found.

1

These are the steps that worked for me on Magento ver. 2.1.7 with Redis (not running Varnish). However, it's still unclear if everything is working as it should. JS is minified and bundled (unclear what merge is supposed to do). CSS is minified (not seeing it merged).

  1. Turn off all Magento cache.
  2. Clear redis cache.
  3. Turn all five css/js configs on (either in admin or via database).
  4. Generate static files.
  5. Clear Magento cache (command line). For safety (may not be required).
  6. Clear opcache (if not set to auto refresh).
  7. Refresh frontend home page (and check browser console for errors).
  8. Turn on Magento cache.

dev/css/merge_css_files = 1 dev/css/minify_files = 1 dev/js/enable_js_bundling = 1 dev/js/merge_files = 1 dev/js/minify_files = 1

Simply turning on the configs and clearing cache didn't work -- the frontend browser console reported a lot of js errors.

  • Merge will merge your files together into one. – ladle3000 Oct 5 '18 at 13:45
0

Have you tried to flush the JavaScript/CSS? You can do this under System>Cache Management and then press the button which is on the bottom of the table on the left 'Flus JavaScript/CSS Cache'

  • YEP.... flush js, then cache. Nothing change. However, if I switch to Developer mode, the merge works. – BrunoBueno Mar 16 '16 at 17:03
0

You need to redeploy static after enabling this option in production mode.

  • The point is, I'm doing it. I just posted here what I did. – BrunoBueno Mar 16 '16 at 17:02
  • If it not works then problem maybe in in permission. Can you check your webserver access/errors log – KAndy Mar 17 '16 at 14:01
0

I just did the following and the problem was solved.

bin/magento setup:upgrade

bin/magento indexer:reindex

bin/magento deploy:mode:set production -s

bin/magento setup:di:compile

(Here was the secret, to run the di:compile after production)

bin/magento setup:static-content:deploy
0

I've had the problem when the JavaScript is un-compiled the jquery selector works.

$('#my_element').click(function(){ alert('Hello World');});

But once compiled, compressed and joined, I then need to code:-

$('body #my_element').click(function(){ alert('Hello World');});

Don't ask why, it seems that when reading directly from the cache, the requirejs code executes before the domReady and the elements attach to different elements in some different page.

-1

Delete cache manually var/cache and delete session manually var/session

-1
  1. Please also enable "Enable JavaScript Bundling" option

    store->configuration->advanced->developer->javascript setting->

  2. Enable JavaScript Bundling set to "yes" And flush cache

  • 2
    Haphazard advice that has nothing to do with the question. – ladle3000 Oct 5 '18 at 13:46

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.