2

Especially after changing .html knockout js template files I have to always deploy static content with bin/magento setup:static-content:deploy <languages>. This makes development very slow. I can just delete all static contents and let it create on the fly but that is no alternative as it will raise page load times to 15+ seconds (sometimes more than a minute.)

How can I improve this situation?

4
  1. delete all your static content
  2. deploy the static content with bin/magento setup:static-content:deploy <languages>
  3. change whatever file you need to change ie. <vendor>/.../web/template/shipping.html
  4. search for shipping.html in pub/static or in var (like view_preprocessed) for other files and delete only the file in question ie. shipping.html
  5. reload the page

Now Magento will use static files except for the file you are working on which will be generated on the fly (or used via symlink). If you want to have it static again just re-deploy static files.

1

You don't need to deploy stuff when you are on developer mode.

This is an essential step in using Magento: never ever leave the mode after the installation.

From the official guide, here:

To improve security and ease-of-use, we added a command that switches Magento modes from developer to production and vice versa.

Production mode also has better performance because static view files are populated in the pub/static directory and because of code compilation.

http://devdocs.magento.com/guides/v2.0/config-guide/bootstrap/magento-modes.html

Long story short, there are 3 modes.

First, default. This is the default (ha!) mode for Magento2. Its not optimized for production mode, nor useful if you want to change something on the system.

Secondly there is developer. Most likely, this is what you want. If you are trying to change stuff on your store, code-wise, you want to enable this. What does it do?

  1. Symlinks to static view files are published to the pub/static directory
  2. Provides verbose logging
  3. Enables automatic code compilation
  4. Enables enhanced debugging Shows custom X-Magento-* HTTP request and response headers
  5. Results in the slowest performance (because of the preceding)

tl;dr: you only need to recompile var/view_preprocessed/* and pub/static/* if you change _less files. If you change __construct-Methods in your module, you generally only need to clear var/generation/*. Anything else will be automatically deployed (with Symlinks). NOTE: This might be harmful to a production system.

Last and least: the production mode. If you enable this mode, you achieve full deployment of files and therefore generally a way faster Magento2 Store. You should also enable all the caches for maximum out of the box speed. Intended for deployment on a production system. Exceptions are not displayed to the user, exceptions are written to logs only, and static view files are served from pub/static only. New or updated files are not written to the file system.

Switch to developer or production mode

In your terminal: php bin/magento deploy:mode:set <mode>

Possible modenames are: developer and production

  • Thanks for your answer. Although this is all true as I wrote the development mode is just too slow for actual development. Deploying static files and just creating the files you are working on sped up development a lot for me. That is what I wanted to share. – steros Apr 25 '17 at 7:50

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.