pranaygp / vscode-css-peek

A vscode extension for peeking at CSS definitions from a class or id tag in HTML
MIT License
146 stars 32 forks source link

Document "cssPeek.*" settings in README #15

Closed ndstephens closed 4 years ago

ndstephens commented 6 years ago

I'm using SCSS for my project, but of course compile it down to regular CSS. Let's say the compiled css file is in my "build" folder which is at the root of my project:

ProjectName/build/compile.css

I would like to exclude the "build" folder so that any and all CSS in there is excluded. Reason being is if i have a ".foo" class in one of my .scss files then there will also be a ".foo" class in the "compile.css" file. When I hover over the class in my html "

" it'll tell me i have 2 definitions. I only want to see the ".foo" definition in my .scss file, not the one in "compile.css" that's in my build folder.

As a hack I realize i can remove ".css" from the "css_peak.searchFileExtensions" setting, but maybe i still have some .css files in my main project i want to search. I just want to exclude those in the "build" folder.

I understand that i need to exclude my build folder (or at least the files in it) using regex according to your settings description. First, i don't know regex which is not your problem and for me to learn. But what i don't know is how to even figure it out, as in, how to write the regex. Do i start from the project root? Does it have to be a string since it's in a json file? An example would help and be greatly appreciated.

If this is the wrong place to ask then I am sorry. I consider it an "issue" since I don't feel there is sufficient documentation to know how to write the regex, even for someone familiar with regex. Maybe i'm mistaken in that thinking.

pranaygp commented 6 years ago

@ndstephens yeah, the "exclude" option, as you seem to have noticed, is just an array of regular expressions that get's matched on the entire file string path:

so, for example, a string file path might look like "build/myCode.css", or "src/myCode.scss".

If you want to exclude everything from "build", then just add "build/" to the array of regular expressions for exclude, and it will ignore everything inside folders called "build".

for reference, the default that the extension uses for exclude is: ["node_modules", "bower_components"]

I agree that this isn't well documented in the README for the repo, and I'm happy to accept a PR if someone would like to add some documentation for it (and perhaps the other CSS Peek options)?

ndstephens commented 6 years ago

@pranaygp thanks for the response. i guess i thought a regex was more complicated than that. i didn't realize it was as simple as just including the folder. i'll definitely try that. thank you.

pranaygp commented 6 years ago

@ndstephens regex starts out that simple, but lets you do a bunch of way more complicated and interesting things. Just to get you more interested, consider that regex, the same thing you're using to simply match on a "build" string for this extension, is what compilers use to parse source code for programming languages.

I would definitely recommend playing around with regular expressions (one of my bookmarked websites: https://regexr.com/) if you'd like to learn more about that :)

pranaygp commented 5 years ago

61 makes some changes since we now use glob patterns instead of regular expressions

cnabildev commented 4 years ago

works fine go to extensions search for CSS Peek >> settings >> enable 👍

pranaygp commented 4 years ago

Updated the README to have some documentation on this