8

A while ago when I was working on a project with Magento 2, I noticed that my CSS and JavaScript files in pub/static of my theme were actually symbolic links to the actual files. This was also when I ran a setup:static-content:deploy action from the shell.

However, I recently migrated to a new system and checked out the code and the database of the project, but now when I deploy my static content, they are copies rather than Symbolic links.

Is something changed? Or am I missing some configuration setting here? It's not very productive to have to re-compile the static content every time I make a change to the JS or CSS.

I'm using Magento 2.0.6

  • Is your store set to developer mode? – Ryan Hoerr May 23 '16 at 17:25
  • Yes, my store is set to developer mode. I also tried switching to production, delete the pub/static-folder, and re-enable developer mode, but without success. All files are copied instead of symlinked. – Giel Berkers May 25 '16 at 9:28
10

Most likely you deleted all of your files in pub folder at some point in past, including:

  1. /pub/static.php
  2. /pub/static/.htaccess

When static file that you are looking for is not found, it redirects request to one folder above to static.php file, which initiates the fallback mechanism and pulls down that file as a symlink.

To resolve the issue copy down fresh copy of Magento 2.x that you are running and copy over those files to your pub folder.

9

Open your di.xml (app/etc/di.xml) and check around line 580 you should find something like this (iam using 2.0.6 and mode is set to devloper): As you can see view_preproccessed are symlinked and default is set to copy.

<virtualType name="developerMaterialization" type="Magento\Framework\App\View\Asset\MaterializationStrategy\Factory">
    <arguments>
        <argument name="strategiesList" xsi:type="array">
            <item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink</item>
            <item name="default" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Copy</item>
        </argument>
    </arguments>
</virtualType>

Also take a look here Magento 2 404 error for scripts and css specially the answer from Chris O'Toole

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.