Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome DevTools save CSS changes directly to SASS file

Tags:

Is it possible to have style changes done directly in the "Styles" panel not only persisted to the .css but also to the corresponding .scss file?

I have CSS source maps for every file and that works fine - I can jump right into the .scss file when I Ctrl-Click a property. I can edit the .scss file then and it reloads correctly (compass task in the background), but unfortunately everything I change directly in the Styles panel is persisted only to the compiled .css file.

Styles panel

As soon as I change a value, the file changes to main.css and the changes are only persisted there:

Styles panel 2

like image 785
Alex Avatar asked Mar 18 '14 16:03

Alex


People also ask

How do I save custom CSS changes in Chrome?

To make things simpler, Chrome only shows you the local resources (so you don't get confused on as to whether you are editing the local or the network resource). To save your changes, press CTRL + S when editing the file.

Does CSS automatically save?

Filling the CSS Profile can be a lengthy process. However, the information gets saved automatically. If you need to log out and continue the application process later, you can pick up right where you left off.

How is CSS compiled to Sass?

Once you start tinkering with Sass, it will take your preprocessed Sass file and save it as a normal CSS file that you can use in your website. The most direct way to make this happen is in your terminal. Once Sass is installed, you can compile your Sass to CSS using the sass command.


1 Answers

SASS/SCSS live editing no longer works as it was depreciated by Chromium team:

https://bugs.chromium.org/p/chromium/issues/detail?id=863408#c5

We used to have the "LiveSASS" experiment a while ago that would propagate changes back to SASS/sourcemapped CSS. The experiment was eventually deprecated and removed due to no clear path forward.

UPDATE: however, sourcemaps still work fine and given that:

  • your CSSs are sourcemapped to SASS files
  • you have added the folder with css/sass to workspace (i.e. Devtools can access them in your filesystem)
  • you're serving your website (or at least .css files) from localhost

you will get .scss files exposed in Devtools' Styles tab.

To edit: just double-click .scss file name and it will be available in Sources tab for editing and saving. Not as streamlined as direct editing in Styles tab, but still quite useful. I do almost all my css-related edits this way.

NOTE: if you change values in Styles tab, changes will persist in your .css files and not .scss! Even though interface shows otherwise.

.scss is exposed and editable by Devtools

Extra hint: if you add a symlink / install your css framework into node_modules so it's accessible to Devtools, you will get access to all framework's sass-files also. Just be careful not to expose whole node_modules to your "live refreshing" Webpack server, as it will choke on 100,000 of files inside node_modules to observe.

like image 80
Benny K Avatar answered Dec 22 '22 08:12

Benny K