1

I am in the middle of a situation regarding the static content deployment and I find it strange.

I built Magento 2 themes based on Luma/Blank or even not based on those. When I was working under the developer mode, I didn't need to deploy static files after each CSS/JS/PHTML change. This is how the developer mode is supposed to work as far as I know.

However, I also worked with other themes developed by third-party providers, well-known in this industry, but I needed to deploy static files even if I was using the developer mode.

To fix this, I tried to apply different solutions such as:

  • remove pub/static/*, excepting the .htaccess file;
  • remove var/view_preprocessed/*;
  • remove deployed_version.txt.

Is this a theme-related error or am I missing something?

1
  • Are the files inside pub/static/frontend/Vendor/Theme/locale/ and all different subfolders in there, symlinks? Or are they actual files? If they are symlinks, updates should happen automatically, after cleaning the cache if cache is enabled. If not a symlink, try to delete that specific file, go to a page where that file is required, and check again, if the file is created as a symlink, or you get an error that file not found. Might check on setting up Grunt
    – Dan Staver
    Commented Mar 29, 2022 at 1:23

1 Answer 1

0

Follow below step properly, After all think working with developer mode and all changes effect in fronted without deploy static files every time.

When Magento 2 is not in production mode, it will try to create symlinks for some static resources on local server. We have to change that behavior of Magento 2 by going to edit ROOT > app > etc > di.xml file. Open up di.xml in your favorite code editor, find the virtualType name="developerMaterialization" section. In that section below, you will find an item <item name="view_preprocessed" xsi:type="object"> which needs to be modified. You can modify it by changing the following content:

Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink

To:

Magento\Framework\App\View\Asset\MaterializationStrategy\Copy

Now last step, also delete old files generated in ROOT > pub > static > DELETE ALL EXCEPT .HTACCESS

In this step, we are setting up static content to deploy on our Magento store. To perform this below step again.

php bin/magento maintenance:enable
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento setup:static-content:deploy --theme Magento/backend -f
php bin/magento setup:di:compile
php bin/magento maintenance:disable
php bin/magento cache:flush
php bin/magento indexer:reindex
sudo chmod -R 777 var/ generated/ pub/media/ pub/static/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.