Magento2 developer mode doesnt generate static files on demand
-
08-10-2020 - |
Frage
I am running Magento 2 locally in developer mode
After installing i would not expect to have to run php bin/magento setup:static-content:deploy
if in developer mode.
However, the only directory under static is _requirejs and all css and other assets generate a 404 on the frontend.
Is the php bin/magento setup:static-content:deploy
command required even in developer mode or do i have an issue with this?
Lösung
If you are in Apache:
- Check you have the correct .htaccess file under pub/static folder https://github.com/magento/magento2/blob/2.2/pub/static/.htaccess. Check https://github.com/magento/magento2/blob/2.2/pub/static/.htaccess#L21 which redirects requests to static.php
- Make sure your mod rewrite module is working properly.
- Make sure apache is reading .htaccess files.
Apache 2.2
AllowOverride All
Order allow,deny
Allow from all
Apache 2.4
AllowOverride All
Require all granted
If you are in Nginx:
Update configurations using https://github.com/magento/magento2/blob/2.2/nginx.conf.sample. Check https://github.com/magento/magento2/blob/2.2/nginx.conf.sample#L111 which redirects requests to static.php
Andere Tipps
Also, if you are running Apache: make sure that mod_rewrite
module is enabled.