Magento – Static files not available in developer mode

developer-modemagento2.2

I'm running Magento 2.2.2 in developer mode.
When I try to display a page, the static files are not available unless I remove all the pub folder content with rm -R pub/static/*
Once it's done, the static files are available only one time. If I refresh the page, they're gone :

Loading failed for the <script> with source “pub/static/adminhtml/Magento/backend/en_US/requirejs/require.js”.

(same error for several other js and css files)

I tried setup:static-content:deploy but it doesn't fix the issue.
After working on it for several hours, my guess is that something is wrong with the symlink but I don't get where, when I use readlink the path is correct : lib/web/requirejs/require.js.

Any help would be greatly appreciated.

Best Answer

When You remove pub/static/* folder, You removed .htaccess file.

Keep in mind never delete pub/static/.htaccess

You can download .htaccess file from the official Magento 2 repository. That will solve your problem.

Related Topic