12

I have a Magento 2.0.2 installation in developer mode and I still can't figure out how to force it to regenerate the static view files whenever I make a change in my CSS.

I verified that I am in developer mode by running php bin/magento deploy:mode:show

On this page it says that developer mode disables static view files caching, but that is not the case for me.

I tried to edit the di.xml as mentionned in this solution but it didn't change Magento's behavior.

How can I tell magento to automatically regenerate static view files?

4

In developer mode, M2 does not generate static files. It should create symlinks to them from the various modules. If you however have ran setup:static-content:deploy and have those files in place, it won't update them. Try removing all static files and see if Magento links to them (be careful not to remove the actual files if you have symlinks)

  • 1
    I tried deleting the whole content of pub/static (without deleting the .htaccess file) and it didn't work. It looks like the old files were regenerated. – AlexandreC Mar 10 '16 at 17:28
  • Currently, the only way I'm able to get the updated content is by clicking 'Flush Static Files Cache' in the Magento Cache Management page. – AlexandreC Mar 10 '16 at 17:31
  • 4
    I had the same problem of symlinks not being generated in developer mode; then I realized I had deleted the .htacces file from pub/static; once I restored the .htaccess file in pub/static the next request regenerated all symlinks; hope it helps. – Alessandro Ronchi Mar 22 '16 at 11:12
  • I have the same problem currently with Magento 2.0.6. Tried re-adding the .htaccess-file (I run nginx, so I didn't think it would do much), and as expected, it didn't work. Previously my symlinks were created, but now not anymore ... – Giel Berkers May 25 '16 at 9:41
  • 1
    As we thought pub/static is autogenerated anyways we also deleted it manually at one point and ran into the same problem. Looks like in our apache2/php7 setup the now missing .htaccess file is really responsible for this. After recreating the original .htaccess developer mode was working fine again. Here the link to the recent .htacces: github.com/magento/magento2/blob/develop/pub/static/.htaccess – Jey DWork May 25 '16 at 17:40
1

Same happened to me. After moving the site to another server, it turned out I didn't set the file permissions correct.

I ran find . -type d -exec chmod 770 {} \; && find . -type f -exec chmod 660 {} \; && chmod u+x bin/magento and that solved my problem.

More info: Magento 2: Recommended File Permission for shared hosting

Update: make sure the pub folder (magento/pub) and the underlying folders have read and write permissions.

  • 2
    Whomever downvoted: why? – Chris K Jan 5 '18 at 19:24
0

Bit late here, but I was experiencing the same issue. I had developer mode enabled for some time, then for some reason (likely an error on my part at some point), it no longer seemed to work.

Simple solution for me was to reset the mode to developer again:

php bin/magento deploy:mode:show developer

NB: You might need to set it to default and then developer.

  • This also didn't help. Any other suggestions? – Adarsh Khatri Jul 4 at 1:50
0

I was facing the same issue with my less updates noting showing unless I flushed my static files. The fix for me was to disable mod_expires. This was caching the css and etc.

Inside of the pub/static/.htaccess file you will should have something like the following:

<IfModule mod_expires.c>

############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires

    ExpiresActive On

    # Data
    <FilesMatch \.(zip|gz|gzip|bz2|csv|xml)$>
        ExpiresDefault "access plus 0 seconds"
    </FilesMatch>
    ExpiresByType text/xml "access plus 0 seconds"
    ExpiresByType text/csv "access plus 0 seconds"
    ExpiresByType application/json "access plus 0 seconds"
    ExpiresByType application/zip "access plus 0 seconds"
    ExpiresByType application/x-gzip "access plus 0 seconds"
    ExpiresByType application/x-bzip2 "access plus 0 seconds"

    # CSS, JavaScript, html
    <FilesMatch \.(css|js|html|json)$>
        ExpiresDefault "access plus 1 year"
    </FilesMatch>
    ExpiresByType text/css "access plus 1 year"
    ExpiresByType text/html "access plus 1 year"
    ExpiresByType application/javascript "access plus 1 year"
    ExpiresByType application/json "access plus 1 year"

    # Favicon, images, flash
    <FilesMatch \.(ico|gif|png|jpg|jpeg|swf|svg)$>
        ExpiresDefault "access plus 1 year"
    </FilesMatch>
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/svg+xml "access plus 1 year"

    # Fonts
    <FilesMatch \.(eot|ttf|otf|svg|woff|woff2)$>
        ExpiresDefault "access plus 1 year"
    </FilesMatch>
    ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
    ExpiresByType application/x-font-ttf "access plus 1 year"
    ExpiresByType application/x-font-otf "access plus 1 year"
    ExpiresByType application/x-font-woff "access plus 1 year"
    ExpiresByType application/font-woff2 "access plus 1 year"

</IfModule>

By disabling mod_expires or commenting out the above and doing a hard refresh in your browser (Mac Users hold down Shift + Command + r) your changes should start showing each time you make them.

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.