Browse Source

get `less` working

Stephan Fuchs 2 months ago
parent
commit
42e38a2aaa

+ 5 - 0
.gitignore

@@ -55,3 +55,8 @@ sugarcube/src/typescript-min.js
 sugarcube/temp/
 
 !.vscode/
+
+# Less Files
+
+sugarcube/src/less.css
+sugarcube/src/main.less

+ 41 - 1
.vscode/tasks.json

@@ -21,7 +21,8 @@
 			},
 			"problemMatcher": [],
 			"dependsOn": [
-				"esbuild"
+				"esbuild",
+				"less"
 			]
 		},
 		{
@@ -95,5 +96,44 @@
 				"TSC"
 			]
 		},
+		{
+			"label": "lessPrecompile",
+			"type": "shell",
+			"command": "python sugarcube/devTools/lessPreCompile/lessPreCompile.py",
+			"presentation": {
+				"echo": true,
+				"reveal": "always",
+				"focus": false,
+				"panel": "dedicated",
+				"showReuseMessage": false,
+				"clear": true
+			},
+			"group": {
+				"kind": "build"
+			},
+			"problemMatcher": [],
+			"dependsOn": [
+				
+			]
+		},
+		
+		{
+			"label": "less",
+			"type": "shell",
+			"command": "lessc sugarcube/src/main.less sugarcube/src/less.css",
+			"presentation": {
+				"echo": true,
+				"reveal": "always",
+				"focus": false,
+				"panel": "dedicated",
+				"showReuseMessage": false,
+				"clear": true
+			},
+			"group": {
+				"kind": "build"
+			},
+			"problemMatcher": [],
+			"dependsOn": ["lessPrecompile"]
+		},
 	]
 }

+ 24 - 0
sugarcube/devTools/lessPreCompile/lessPreCompile.py

@@ -0,0 +1,24 @@
+import os
+
+def find_less_files(folder_path):
+    less_files = []
+    for root, dirs, files in os.walk(folder_path):
+        for file in files:
+            if file.endswith('.less'):
+                less_files.append(os.path.relpath(os.path.join(root, file), folder_path).replace('\\','/'))
+    return less_files
+
+def write_paths_to_file(file_paths, output_file):
+    with open(output_file, 'w') as f:
+        for path in file_paths:
+            f.write(f'@import "{path}";' + '\n')
+
+if __name__ == "__main__":
+    folder_path = "sugarcube/src"
+    output_file = "sugarcube/src/main.less"
+    if os.path.exists(output_file):
+        os.remove(output_file)
+    
+    less_files = find_less_files(folder_path)
+
+    write_paths_to_file(less_files, output_file)

+ 0 - 0
sugarcube/src/style/general.css → sugarcube/src/style/general.less