1

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.

Ghulam.M
9738 silver badges25 bronze badges
asked Nov 26, 2017 at 20:47
2
  • if you chnage css in development mode you d'ont need to redeploy onlye clear the cache magento and your navigator cache Commented Nov 26, 2017 at 21:00
  • checkout here magento.stackexchange.com/a/187029/54588 Commented Nov 27, 2017 at 3:48

5 Answers 5

4

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
answered Aug 2, 2018 at 0:53
0

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.

enter image description here

answered Nov 26, 2017 at 21:09
4
  • is there a command to flush static file cache in production mode or do I have to manually delete the files? Commented Nov 26, 2017 at 21:13
  • @helefa I suggest doing it from admin (see edit) Commented 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... Commented 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/* and rm -R var/view_preprocessed/* from CLI Commented Nov 26, 2017 at 21:28
0

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

answered Nov 27, 2017 at 3:07
0

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

answered Nov 27, 2017 at 21:44
0

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
Abhishek Panchal
4,9643 gold badges22 silver badges39 bronze badges
answered Nov 26, 2017 at 22:07
1
  • 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 used Commented Oct 21, 2019 at 17:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.