0

On one of my website, sometimes some of my custom js not working, I have embeeded on template file. I have checked console of browser it shows error, also sometimes css or some portion like sign in/sign out or logo will not display.

to fix it i have to run content deploy every time, i just need to know the root cause of it. What will be the best practices to fix these kind of issue, so that i don't have to run content deploy everytime, as website is already live, and it seems very disappointing if suddenly some function stop working.

Also, i have noticed that content deploy is not working with -f, is that was also a issue, which brings these problems.

Thanks

  • Which mode you are using ? – Pawan Nov 28 '18 at 11:54
  • currently its development mode. – John Nov 28 '18 at 12:18
  • have you added JS code to phtml file ? Please also share what code you have added ? – Pawan Nov 28 '18 at 12:39
  • yes i did it in on template file. It was a plain js script for validating form nothing else. script is working fine without throwing any error on console logs. – John Nov 28 '18 at 12:44
0

You can run the static-deploy in verbose mode with -vvv and that might show more output assuming its hitting an error when your custom JS is not there.

0

Can you please try the steps as describe below.

I assume , Magento is on Developer mode while you follow below steps.

step 1) Please Go to Admin panel and navigate to STORES -> Configuration -> ADVANCED -> DEVELOPER .

Click on "JavaScript Settings" to expand it.

Step 2) Please set JavaScript Settings as follows:

  • Merge JavaScript Files : Yes
  • Enable JavaScript Bundling : No
  • Minify JavaScript Files : No

Step 3) Run Following CLI commands form your Magento 2 root directory to remove static files,generated files, cache files.

sudo rm -rf var/view_preprocessed/*
sudo rm -rf var/pub/static/*
sudo rm -rf var/cache/*
sudo rm -rf var/generated/*
sudo rm -rf var/page_cache/*
sudo rm -rf var/view_preprocessed/*
sudo rm -rf pub/static/frontend/*

step 4:) Again please run below CLI commands to set Production mode

sudo php bin/magento deploy:mode:set production -s

sudo php bin/magento setup:di:compile

sudo php bin/magento setup:static-content:deploy

Step 5) Run below commands to set permission to pub,var and generated folder

sudo chmod -Rv 777 pub var generated

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.