8

I have installed Magento 2.1.0 successfully and also created many modules.

Suddenly after every php bin/magento setup:upgrade command , its not generating static contents.

The problem is after every setup:upgrade needs to have static content deploy command otherwise no CSS and JS works. If anyone can suggest me for a solution and the reason would be appreciable.

deploy mode is : developer

Nikunj Vadariya
4,0371 gold badge21 silver badges30 bronze badges
asked Oct 24, 2016 at 13:18
2
  • in Magento documentation: Developer mode:Static view files are not cached; they are written to the Magento pub/static directory every time they’re called Commented Oct 24, 2016 at 14:06
  • Thank w.k, Yes if mode is set to developer then it must auto generate static content but that is the issue here. even though mode is set to developer static content are not auto generating after every upgrade command. Commented Oct 25, 2016 at 7:10

3 Answers 3

5

I agree with you here in terms of needing to do this each time.

I am called to run setup:static-content:deploy with each upgrade and I have two languages so I need to run with the locale flag next to it, ie:

php bin/magento setup:static-content:deploy en_US <other locals>

However, we do have the option of --keep-generated with setup:upgrade. See the help:

php bin/magento setup:upgrade --help
Usage:
 setup:upgrade [--keep-generated] [--magento-init-params="..."]
Options:
 --keep-generated Prevents generated files from being deleted. 
 We discourage using this option except when deploying to production. 
 Consult your system integrator or administrator for more information.
 --magento-init-params Add to any command to customize Magento initialization parameters
 For example: "MAGE_MODE=developer&MAGE_DIRS[base][path]=/var/www/example.com&MAGE_DIRS[cache][path]=/var/tmp/cache"
 --help (-h) Display this help message
 --quiet (-q) Do not output any message
 --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
 --version (-V) Display this application version
 --ansi Force ANSI output
 --no-ansi Disable ANSI output
 --no-interaction (-n) Do not ask any interactive question

It will keep static content.

answered May 17, 2017 at 17:21
2

setup:upgrade wipes everything. It is like manually emptying the generated, pub, and cache folders. If you do not deploy again, there won't be any files to build from.

answered May 5, 2021 at 19:56
1

To regenerate the static content (html, css, js) the command is:

php bin/magento setup:static-content:deploy

This will generate the static assets under pub/static.

Otherwise you can combine 2 commands with &&:

php bin/magento setup:upgrade && php bin/magento setup:static-content:deploy 

This will concatenate the 2 commands in 1, in particular if the first one is successful the second will be executed.

answered Nov 2, 2016 at 15:01
2
  • Elio thanks but you have not understood my question. I know this command is used to generated static contents.But my problem is whenever I run "php bin/magento setup:upgrade" command, it is also needed to run command - "php bin/magento setup:static-content:deploy" to generate css and js which is time taking. If I run "php bin/magento setup:upgrade" it should not ask for "php bin/magento setup:static-content:deploy" , what action should be taken for it. Commented Nov 5, 2016 at 8:06
  • hi @SPK see my updated answer if can solve your question. Commented Nov 7, 2016 at 12:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.