3

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!

  • From my experience so far, all the .html and .js files do not update unless you do a static-deploy after deleting the generated file in pub/static. What should happen is a symlink to the working file should be created when you are working on a file, but that doesn't happen for me. My work around is just to edit the .html and .js files in pub/static till i get what i need and then copy that code over to the file in my theme. But this is just my experience so far, so it's not a real answer. – circlesix Jul 16 '16 at 16:58
  • I posted my solution, as it works now for me. – remklov Jul 22 '16 at 7:09
4

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

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.