emmetio / livestyle-sublime-old

Live bi-directional CSS edit of new generation
http://livestyle.emmet.io
260 stars 23 forks source link

does not work with .css?ver=xx #150

Closed sebszocinski closed 8 years ago

sebszocinski commented 9 years ago

I am using the Alpha version as the previous one stopped working.

If I have dev tools closed and click the LS button in chrome I can see all my style sheets and select one and then coding in ST will update Chrome, but once I open Dev Tools and then click on the LS icon only ONE stylesheet is listed and it is an external one hosted on a CDN...

The only difference I can see if that i'm using ?ver with Wordpress on my stylesheets.

Edit: Confirmed, if I remove ?ver=xx then it works!

Hope you can fix this!

Cheers

slifin commented 8 years ago

I came here to report the same issue

css files can be linked up in the extension UI, but when you go to edit them no syncing occurs seems to affect css files that use get parameters

sergeche commented 8 years ago

Will fix it as soon as I get back to LS plugin, working on LS web-site right now

geckoseo commented 8 years ago

It seems to stabilise if you strip the query strings from the stylesheets.

If you are using a Wordpress Child theme, you can use this function to patch the problem (At least it seems to patch it, have not tested it for very long at time of writing).

If you want to keep the parameters on the JS files, just remove script loader filter from the function.

If you are not using a child theme, there must be a plugin in the WP repository that strips query params, or you can use W3 Total Cache.

If you are a theme developer, just remove the params while you are developing.

PHP FUNCTION:

//Remove Query Strings from Static Resources
function remove_cssjs_ver( $src ) {
 if( strpos( $src, '?ver=' ) )
 $src = remove_query_arg( 'ver', $src );
 return $src;
}
add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 );
add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 );` 
geckoseo commented 8 years ago

Just to confirm, after a day or so of testing in my own environments, LS Alpha, in the context of this discussion, is stable in Chrome when editing WP stylesheets, as long as the query strings are stripped from the file location.

sergeche commented 8 years ago

Fixed in v0.9.4 Chrome extension