2021-09-09 12:03:42 +00:00
|
|
|
'''
|
|
|
|
Use this when you modified any css in the css/ folder.
|
|
|
|
'''
|
|
|
|
|
2021-09-09 13:23:44 +00:00
|
|
|
import os
|
2021-09-09 12:03:42 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
from csscompressor import compress
|
|
|
|
except ModuleNotFoundError:
|
|
|
|
os.system("python -m pip install csscompressor")
|
2021-09-09 13:23:44 +00:00
|
|
|
from csscompressor import compress
|
2021-09-09 12:03:42 +00:00
|
|
|
|
|
|
|
def main():
|
|
|
|
not_minified = [f"./css/{f}" for f in os.listdir("./css") if not f.endswith(".min.css")]
|
|
|
|
|
|
|
|
for file in not_minified:
|
|
|
|
print(file)
|
|
|
|
with open(file, "r") as input_file:
|
|
|
|
css_minified = compress(input_file.read())
|
|
|
|
|
|
|
|
with open(f"{file.replace('.css', '')}.min.css", "w") as output_file:
|
|
|
|
output_file.write(css_minified)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2021-09-09 13:23:44 +00:00
|
|
|
main()
|