Magento2: Re generate css file in pub/static folder
Before deleting pub/static make a backup of pub/static/.htaccess and restore it again. otherwise your all css and js will show 404 error!
- Remove
pub/static
(keep the .htaccess backed up and copy it again) - Remove
var/cache
- Remove
var/composer_home
- Remove
var/generation
- Remove
var/page_cache
- Remove
var/view_preprocessed
- Run
php bin/magento setup:static-content:deploy
answers here don't mention that you shouldn't delete the .htaccess in the pub/static folder.
to delete all files except the .htacces enter the pub/static directory and run
find . -depth -name .htaccess -prune -o -delete
then you can run
rm -rf var/cache/ var/generation/ var/page_cache/ var/view_preprocessed/
I have just delete the css files from pub/static
folder and run the command:
php bin/magento setup:static-content:deploy
It will re generate the same file with latest changes.