Magento 2 Deploy CSS Updates - css

I am trying to figure out a way to move in css updates in production mode without any downtime or maintenance mode enabled.
For example, if I update something in theme's style.css, I will need to run the commands below to get the css updates included in the merged css file.
rm -rf var/view_preprocessed/*
rm -rf pub/static/frontend/*
php bin/magento setup:static-content:deploy
php bin/magento cache:flush
But this will create downtime. Running deploy command along will not update the css.
Any suggestions?

Related

Magento 2 - Symlinks not created in dev mode

Environment:
- Magento 2.3
- Mode: Developer
- Cache: Disabled
- empty: pub/static, except .htaccess
- empty: var/cache, var/composer_home, var/page_cache, var/view_preprocessed
From there it is my understanding that if you reach the website through a browser, considering there are no static files ready to use yet, then Magento will either copy (production mode) or symlink (developer mode) the required css/js to pub/static folder for the theme used (as well as parent themes for the required files), so that the website can load properly and accordingly.
But what happens instead in developer mode, it creates a single file:
pub/static/frontend/Vendor/theme_name/en_US/requirejs-config.js
Any idea why the symlinks are not generated and what's happening, why this single file requirejs-config.js is generated?
PS: we do not want to deploy static content.
You can try this command
bin/magento dev:source-theme:deploy instead of bin/magento setup:static-content:deploy -f
In command line :
php bin/magento setup:upgrade
php bin/magento setup:di:compile
Clear your navigator's cache and try to reload your page.
If it still doesn't work :
php bin/magento setup:static-content:deploy -f
php bin/magento setup:upgrade
Clear your navigator's cache and try to reload your page again.
Hope it's help.
try this
php bin/magento setup:static-content:deploy -f en_US yourlang_YourLang

Removed Stylesheet from application but it still appears on Heroku

I remove a stylesheet that contained media queries for specific devices. The changes appear on my local version. When I view it in production on heroku the media queries are still there. I asset removed it from the assets initializer # Rails.application.config.assets.precompile += %w( apps.css ). I ran heroku run assets:clean and restarted the server but it still remains. git status shows that there are not uncommitted changes.
You will have to do a couple of more steps:
$ rake assets:precompile
$ git add .
$ git commit
... deploy to heroku
rake assets:clean just removes the compiled assets locally; without running the precompile step to generate new assets, the assets on heroku does not get refreshed.

cron Symfony2 to delete a file

I would like to create a cron that remove a file every 24hrs but it doesn't work for me !
emptyCache.php permission 755
rm -rf app/cache/*
I use for that a cron from OVH to do the job, I follow the process but the folder wasn't removed! My question is: is it the right command?
Here is an example of script which should work on a OVH hosting (Pro 2014), you don't need to use any PHP or Symfony2 file or command:
File: /homez.807/[my_login]/symfony2/launch_commands.php
#!/bin/bash
rm -rf /homez.807/[my_login]/symfony2/app/cache/*
It's simpler to put the full path of the directory you want to erase, but you can also use the cd command to change the directory then delete the sub-directory.
And here is the configuration in the OVH manager (see the Cron tab):
So the ./ is the root of you web hosting, corresponding to /homez.807/[my_login]/. Here are the two important options :
Script: we have to put the relative path (from the root of the web hosting) of the script: symfony2/launch_commands.sh
Language: Other because the script should be executed by the shell, not the PHP interpreter
Logs: you should enable logs in order to send the result of the cron task by email
Description: choose an explicit name

How to get assetic to update assets in dev enviroment in symfony2?

I have the issue that my assets, e.g. my sass and javascript, did not recompile on file modification. I installed I accessed them via symlink option and access the dev environment via localhost:8000. I have to manually call /app/console assetic:dump for them to update.
How do I get assetic to watch for file modification?
You can also use
php app/console assetic:dump --watch
If you want to watch for file modifications. This will re-run assetic:dump in the background automatically for you.
And yes dont forget if you use dev then access your site via app_dev.php
And small note... when you use production environment then make sure you execute assetic:dump with --env=prod (without --watch as well)
I realized I have to access the dev page with app_dev.php:
localhost:8000/app_dev.php/
Try to execute:
php app/console assetic:dump --env=dev

CSS not showing as same as local on Heroku

Here's what I did already before thinking this is a duplicate.
I let heroku do the rake assets:precompile
I did it locally, added it to git and pushed
None of these worked? I am thinking maybe Heroku somehow cached the assets which doesn't make sense to me but I have no other ideas at this point. Is this cache idea really possible on Heroku?
As far as I know Heroku doesn't cache any assets.
Try to run the following:
rm -rf public/cache
git commit -am "Removing cache files"
git push heroku master
If it doesn't work try this:
rm -rf public/cache
RAILS_ENV=production bundle exec rake assets:precompile
git add public/cache
git commit -am "Updated Compiled assets"
git push heroku master
You've probably already read Rails Asset Pipeline on Heroku Cedar, if not check it out.
Hope it helps.

Resources