58

Is there a way to get a list of the custom CSS changes you applied within the Chrome dev tools?

When you're playing with CSS in the Chrome dev tools to get your web page look right, it would come in handy to easily track the changes you made.

I know about workspaces, but the use case is an Angular 5 app where your CSS is bundled and possibly minified.

To clarify:

  • I have a page that is looking pretty far from what it should look like
  • I do 20 CSS fixes in dev tools until it looks good
  • now I want to get a (CSS) delta from the original page so I have a list of changes I should now implement in the real CSS styles.
TylerH
  • 20,799
  • 66
  • 75
  • 101
S. Robijns
  • 1,529
  • 3
  • 14
  • 17

5 Answers5

48

You can see all changes via the Changes Drawer

Changes Drawer

In Dev Tools, you can locate the Changes Drawer via either:

  • A) Open Command Palette (Ctrl + Shift + P) and type "changes"

    Command Palette > Changes

  • B) Open Drawer (Esc), click on the more options menu (triple dot), and select Changes

    Drawer Menu > Changes

Further Reading

Updates

KyleMit
  • 30,350
  • 66
  • 462
  • 664
  • 5
    When the CSS is minified and becomes a one-liner, it is quite hard to find the changed items. Activating the pretty-print also makes all the new pretty-printed CSS to be considered as "changes", which defeats the purpose. Is there a way around this? – pokumars Aug 30 '21 at 02:44
  • 2
    I'm unable to select, copy or interact in any way with the changes I made. It's so close and at the same time so far away... – Neithan Max Jan 11 '22 at 13:05
  • @pokumars, this should be fixed in dev tools 98 which automatically pretty prints CSS in the changes drawer – KyleMit Feb 10 '22 at 14:21
  • 2
    @NeithanMax, strong agree - I opened a ticket in the chromium bug tracker so hopefully it'll be addressed in a future cycle – KyleMit Feb 10 '22 at 14:22
  • Logged into my personal stack overflow account just to like and say thank you – EvanPoe May 25 '22 at 15:40
  • 1
    this doesn't work if the changes you make are to the no-rule element style, the first one in the Styles editor. This is because they are applied as inline styles. – rob Jan 11 '23 at 14:38
  • I'm a Chrome user, but this feature appears to work much better in Firefox. It tracks CSS changes no matter how you make them, including inline styles. – JWess Jul 05 '23 at 17:58
25

Actually you could do exactly what you want:

Go to Sources > > Local Modifications

Going to the Sources tab, choosing your desired CSS file, and then right click and choose Local modifications will give you a diff style summary of your local changes.

Local CSS modifications in Chrome dev tools

Or - you could just save the changes directly to a local CSS file by mapping that local file so that chrome dev tools will automatically save any change that you made to this CSS file.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Obmerk Kronen
  • 15,619
  • 16
  • 66
  • 105
  • 3
    I don't have these options in the context menu – winklerrr Oct 15 '20 at 09:29
  • 1
    I do not see these either – Chris Lang Mar 13 '21 at 20:18
  • 1
    I asked this as well on the accepted answer but - When the CSS is minified and becomes a one-liner, it is quite hard to find the changed items. Activating the pretty-print also makes all the new pretty-printed CSS to be considered as "changes", which defeats the purpose. Is there a way around this? – pokumars Aug 30 '21 at 02:46
6

That depends on how you apply css fixes.

  • If you apply css code inline,you can't get a file with list of fixes you made.

  • If you made your changes in inspector-stylesheet you can find that file with all your fixes

    Go to Source tab > from the left list open localhost > you can see file called inspector-stylesheet.

    Which will show all your fixes.

    custom css fix (image)

    css changes file (image)

Another way to pick your css fixes from 'Elements' tab in dev tool you can easy copy edits you made and paste it in your css file of your project or you can edit source file itself from 'Source' tab in dev tool you have two things to do to keep what changes you made:

  1. By pressing Ctrl + S or Cmd + S to save changes and automatically will save changes in your root css file in your project files.

  2. You can copy and paste changes from dev tool to your css file in your code editor

KyleMit
  • 30,350
  • 66
  • 462
  • 664
Amir Fawzy
  • 468
  • 5
  • 12
0

Well, I learned something new

How to monitor changes to inline styles in console

https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver

references: https://hacks.mozilla.org/2012/05/dom-mutationobserver-reacting-to-dom-changes-without-killing-browser-performance/

const targetNode = document

// Options for the observer (which mutations to observe)
const config = { attributes: true, childList: true, subtree: true };

// Callback function to execute when mutations are observed
const callback = function(mutationsList, observer) {
    // Use traditional 'for loops' for IE 11
    for(let mutation of mutationsList) {
        if (mutation.type === 'childList') {
            console.log('A child node has been added or removed.');
        }
        else if (mutation.type === 'attributes') {
            console.log('The ' + mutation.attributeName + ' attribute was modified.');
            console.log({
              mutation, 
              inline: mutation.target.style[0], 
              style: mutation.target.style[mutation.target.style[0]]
            })


        }
    }
};

// Create an observer instance linked to the callback function
const observer = new MutationObserver(callback);

// Start observing the target node for configured mutations
observer.observe(targetNode, config);

This does not solve the problem

but could be used as a starting point for a custom solution to the problem.

custom diffing of each element replacing old values with the latest values you could end up with a diff of all changes up to this point using your own maintained list.

This could be a pr to each of the browsers or created as a chrome extension. Goodluck, wanted to present a possible solution instead of saying it was impossible.

Michael Dimmitt
  • 826
  • 10
  • 23
-1

I know it's "another" subject, but you can try to launch it in some live checker extension in VS Code in order to follow everything...

TylerH
  • 20,799
  • 66
  • 75
  • 101
scoop96
  • 11
  • 4
  • 1
    Thanks scoop96, can you expand a little more on what you mean by that? – KyleMit Aug 20 '20 at 17:08
  • Yes, there are extensions like live server that compile on the go the css and everything. Some of them have logs or mini terminals inside vscode. You could try if it fits you – scoop96 Aug 20 '20 at 18:18