I was working with magento 2 and trying to change some css whenever i change single line of css forexample i was trying to change the _module.less file in Magento_Theme/web/css/source whenever i change sinle line of it didnt show any change but when i remove content from pub/static folder and var/cache and var/view_preprocessed then i am able to see the change what could be the better solution for it to save time ? I am in a developer mode .
If you are in developer mode, you should be able to just refresh the page. Personally, I use grunt and livereload. However, if you are not using those, I find it helpful to do the following when I first start:
- rm -rf pub/static/frontend
- rm -rf var/cache
- rm -rf var/page_cache
- rm -rf var/view_preprocessed
- php bin/magento cache:disable full_page block_html
- php bin/magento cache:clean
- php bin/magento setup:static-content:deploy --area=frontend (this isn't truly necessary but I always do this when I begin the task and NOT on each change)
Also, if you still don't see the changes, flush your browser cache.
If your are editing
less files you need to follow the steps mentioned on other answers. Or configure grunt task runners to compile the less once a file is changed.
Always Use developer mode when you are making changes to website.
For me, after making CSS/JS changes, i need to clear magento cache by running
php bin/magento cache:clean
and then clear Browser cache (Ctrl+Shift+Delete and Clear cache)
If you are changing in less file and want reflection of your changes withour removing static content, you should use client side compilation instead of server side compilation. Check this for more information:https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/css-topics/css-preprocess.html