Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jhancock532/22aa79d7783d30add67fc5bacbd69c02 to your computer and use it in GitHub Desktop.
Save jhancock532/22aa79d7783d30add67fc5bacbd69c02 to your computer and use it in GitHub Desktop.
If you're importing scss files in your project using a glob, this snippet will rename and output the new imports. WIP draft
import glob
import os
scss_files = glob.glob('**/patterns/**/*.scss', recursive=True)
main_scss = ""
working_dir = os.getcwd()
for file in scss_files:
import_script = '@import '+ "'" + file
main_scss += import_script
main_scss += "\n"
head, tail = os.path.split(file)
old_file_path = file
new_file_path = os.path.dirname(file) + "/_" + tail
# os.rename(old_file_path, new_file_path)
f = open("main-imports.scss", "w")
f.write(main_scss)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment