-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reduce 5kb by compressing media queries
- Loading branch information
1 parent
d8e816d
commit efc1450
Showing
7 changed files
with
96 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import os | ||
import re | ||
from collections import defaultdict | ||
|
||
def extract_icons(directory): | ||
icons = defaultdict(set) | ||
pattern = r'i-(?:\w|-|_)+:(?:\w|-|_)+' | ||
|
||
for root, _, files in os.walk(directory): | ||
for file in files: | ||
if file.endswith(('.js', '.jsx', '.ts', '.tsx')): | ||
file_path = os.path.join(root, file) | ||
with open(file_path, 'r', encoding='utf-8') as f: | ||
content = f.read() | ||
matches = re.findall(pattern, content) | ||
for match in matches: | ||
icons[match].add(file_path) | ||
|
||
return icons | ||
|
||
# Usage | ||
src_directory = './src' # Replace with your src directory path | ||
extracted_icons = extract_icons(src_directory) | ||
|
||
# Print the extracted icons and their associated files | ||
for icon, files in sorted(extracted_icons.items()): | ||
print(f"Icon: {icon}") | ||
for file in sorted(files): | ||
print(f" - {file}") | ||
print() | ||
|
||
# Write the icons and their files to a text file | ||
with open('extracted_icons_with_files.txt', 'w') as f: | ||
for icon, files in sorted(extracted_icons.items()): | ||
f.write(f"Icon: {icon}\n") | ||
for file in sorted(files): | ||
f.write(f" - {file}\n") | ||
f.write("\n") | ||
|
||
print(f"Extracted {len(extracted_icons)} icons. Results saved to 'extracted_icons_with_files.txt'") |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters