Magento2 Deployment Workflow – Changes Not Deployed

deploymentmagento2workflow

I am working with Magento2 and have the problem, that my changes are only visible after a full php bin/magento setup:static-content:deploy en_US.

Prerequisites:

  • Magento 2.1.0
  • Linux VM with Apache / PHP7
  • Developer mode active
  • Caches inactive and flushed

I changed a html-file for a ko-template in a custom module, and tried to see the changes in frontend without a full static deploy. But it still displayed the old code. According to different people i asked and digged through blogs / docs i found out, i should remove these directories:

  • pub/static/frontend
  • var/di
  • var/view_preprocessed
  • var/generation

The .htaccess in pub/static was not removed. But after doing this, no JS / CSS files were available in browser and also were nothing was generated in pub/static/frontend except the _requirejs directory.

I ran out if ideas and working like this is really slow and annoying. According to other developers, it should work like this. What is the correct workflow here?

I apprechiate your help!

Best Answer

So i got it working. I will post here a general guide for the developer mode and what needs to be done. With the shown shell commands i assume that you are in your Magento2 root directory.

To get the developer workflow up and running, there are a few things to do. First, activate developer mode in magerun: bin/magento deploy:mode:set developer. To be sure developer mode is active, check your app/etc/env.php if the developer mode is set: 'MAGE_MODE' => 'developer'. After this, also add / uncomment this line in .htaccess and pub/.htaccess SetEnv MAGE_MODE developer. After this, remove all your static and generated content: rm -rf var/page_cache/* var/view_preprocessed/* var/generation/* var/cache/* pub/static/*

IMPORTANT: Check that no uncommented content is after this command! SetEnv MAGE_MODE developer #Comment will not work. This caused the problem in my case, because in the default htaccess a comment exists.

Original pub/.htaccess line: # SetEnv MAGE_MODE default # or production or developer

Related Topic