I've spent a few days reading complex questions and answers on this topic. I'm looking for clear instructions regarding how to make simple edits like changes to CSS in my magento2 site. Is it possible to do so in production mode?
At the moment, I'm unable to see changes to the CSS in BOTH development and production mode. I've tried editing both the style.css file in my theme and the .less file in the theme web/css/source folder.
Running commands like
php bin/magento setup:static-content:deploy
isn't doing anything.
-
if you chnage css in development mode you d'ont need to redeploy onlye clear the cache magento and your navigator cacheMohamed El Mrabet– Mohamed El Mrabet2017年11月26日 21:00:53 +00:00Commented Nov 26, 2017 at 21:00
-
checkout here magento.stackexchange.com/a/187029/54588Manoj Deswal– Manoj Deswal2017年11月27日 03:48:02 +00:00Commented Nov 27, 2017 at 3:48
5 Answers 5
In a production mode you can use the sequence of commands below to regenerate the css files. Specially if you're using less files.
It's not required in developer and default modes.
rm var/view_preprocessed/* pub/static/frontend/* \
&& php bin/magento setup:static-content:deploy en_AU en_US
Make sure you are editing the correct css/less files that are located in app/design/frontend/{vendor}/{theme}/web/css and not the ones in pub/static.
After you make changes, first flush the static files cache and refresh the page cache in Magento admin.
This works in developer mode.
-
is there a command to flush static file cache in production mode or do I have to manually delete the files?helefa– helefa2017年11月26日 21:13:27 +00:00Commented Nov 26, 2017 at 21:13
-
@helefa I suggest doing it from admin (see edit)Lez– Lez2017年11月26日 21:17:45 +00:00Commented Nov 26, 2017 at 21:17
-
according to this devdocs.magento.com/guides/v2.0/howdoi/clean_static_cache.html, it's only available in dev mode...helefa– helefa2017年11月26日 21:20:42 +00:00Commented Nov 26, 2017 at 21:20
-
@helafa You are right. In my opinon you should be in developer mode if you're still making changes to your site. But if you're in production, then use
rm -R pub/static/*andrm -R var/view_preprocessed/*from CLILez– Lez2017年11月26日 21:28:37 +00:00Commented Nov 26, 2017 at 21:28
You can use grunt to manage Magento tasks http://devdocs.magento.com/guides/v2.2/frontend-dev-guide/tools/using_grunt.html
http://devdocs.magento.com/guides/v2.2/frontend-dev-guide/css-topics/css_debug.html
Then use grunt clean - this command will clean all statics file
maybe its the client side. Your browser may cached the static files
if you are using browser like chrome, right click, select inspect, select network, and tick checkbox disable cache
hit refresh F5 without closing the inspect
I recently had an issue exactly the same. I suggest you try what worked for me and Clear var/view_preprocessed directory and then redeploy using the below commands
php bin/magento setup:static-content:deploy --language en_GB
php bin/magento cache:clean
php bin/magento cache:flush
-
I think there might be an error in your first command, it would be php bin/magento setup:static-content:deploy en_GB was what worked for me. The --language option needed to not be usedP_V– P_V2019年10月21日 17:30:20 +00:00Commented Oct 21, 2019 at 17:30