Magento – Why clear pub/static/frontend after css changes in dev mode

cachecsslessmagento2

I am working with Magento2 and have a question. I am working in the development mode.

But when I do some CSS changes in my theme, why I have to manually clear the pub/static/frontend folder every time (when I am in the developer mode).
This is very very slow.

How can I work faster?

Best Answer

Developer Mode - Static Files - Basics

If Magento can’t find a static asset file, it will automatically copy or symlink that file from that file’s source module.


Generate Case

If you change the content of test.css, when you load page, Magento look into the pub/static folder if test.css file not found, it creates from your module or theme.

Not Generated Case

If you change the content of test.css, when you load page, Magento look into the pub/static folder if the test.css file already exist, it skips the generation step so here you need to generate static content manually or remove that particular file from pub static.


Your question solved by two ways

  1. In developer mode you don't need to generate static content every time for single css change. Instead you can just delete that particular file from pub/static folder and then clear cache of magento and browser then load page it will get reflect.

You can use shell script for avoid long typo

    rm -rf var/*
    rm -rf pub/static/frontend/Vendor/theme/en_US/css/test*
  1. You can use grunt for instant changes

Please refer this link for more details