|
|
@@ -37,6 +37,7 @@ templates = source / pathlib.Path("./templates/")
|
|
|
app_view_file = templates / pathlib.Path("view.html")
|
|
|
script_loader_file = script_source / pathlib.Path("loader.js")
|
|
|
sass_loader_file = sass_source / pathlib.Path("loader.sass")
|
|
|
+sass_loading_screen_file = sass_source / pathlib.Path("loading-screen.sass")
|
|
|
config = root / pathlib.Path("config.json")
|
|
|
|
|
|
# Build dir
|
|
|
@@ -46,6 +47,8 @@ build = root / pathlib.Path("./build/")
|
|
|
app_view_result_file = build / pathlib.Path("index.html")
|
|
|
script_loader_result_file = build / pathlib.Path("bundle.js")
|
|
|
sass_loader_result_file = build / pathlib.Path("bundle.css")
|
|
|
+sass_loading_screen_tmp_file = build / pathlib.Path("loading-screen.css")
|
|
|
+static_files_output = build / pathlib.Path("static")
|
|
|
|
|
|
# Checking that directories exists
|
|
|
if not source.is_dir():
|
|
|
@@ -88,6 +91,11 @@ if not sass_loader_file.is_file():
|
|
|
print("SASS loader file not exists.")
|
|
|
exit(-1)
|
|
|
|
|
|
+# Check that SASS loading screen file exists
|
|
|
+if not sass_loading_screen_file.is_file():
|
|
|
+ print("SASS loading screen file not exists.")
|
|
|
+ exit(-1)
|
|
|
+
|
|
|
# Prepare result directory
|
|
|
if build.is_dir():
|
|
|
shutil.rmtree(build)
|
|
|
@@ -153,22 +161,18 @@ def compile(*command: list) -> None:
|
|
|
|
|
|
# Rendering app view
|
|
|
from source.make.render import render
|
|
|
-from source.make.dom import link, script
|
|
|
+from source.make.dom import link, script, style
|
|
|
|
|
|
app_view_render = render(app_view_file)
|
|
|
|
|
|
# App view use HTML description as replace tags
|
|
|
-app_view_render.start_tag = "<!--"
|
|
|
-app_view_render.stop_tag = "-->"
|
|
|
+app_view_render.start_tag = "{{"
|
|
|
+app_view_render.stop_tag = "}}"
|
|
|
|
|
|
view_params = get_config_section("view-params")
|
|
|
|
|
|
# Replace all elements from view-params config section
|
|
|
for param in view_params.keys():
|
|
|
- if param == "bundle_items":
|
|
|
- print("Can not use param \"bundle_items\", it is reserved.")
|
|
|
- exit(-3)
|
|
|
-
|
|
|
content = view_params[param]
|
|
|
|
|
|
if type(content) is str:
|
|
|
@@ -182,6 +186,23 @@ for param in view_params.keys():
|
|
|
print("Param " + param + " not contain string or number.")
|
|
|
exit(-3)
|
|
|
|
|
|
+# Compile loading screen sass file
|
|
|
+compile(
|
|
|
+ "sass",
|
|
|
+ "--sourcemap=none",
|
|
|
+ "-t compressed",
|
|
|
+ str(sass_loading_screen_file),
|
|
|
+ str(sass_loading_screen_tmp_file)
|
|
|
+)
|
|
|
+
|
|
|
+# Open compiled tmp file, add it to view, and drop tmp file
|
|
|
+loading_screen = style()
|
|
|
+
|
|
|
+with sass_loading_screen_tmp_file.open() as handle:
|
|
|
+ loading_screen.content = handle.read()
|
|
|
+
|
|
|
+sass_loading_screen_tmp_file.unlink()
|
|
|
+
|
|
|
# Generating tags
|
|
|
sass_link = link()
|
|
|
sass_link.rel = "stylesheet"
|
|
|
@@ -191,7 +212,11 @@ sass_link.href = "./" + sass_loader_result_file.name + "?version=" + release
|
|
|
js_script = script()
|
|
|
js_script.src = "./" + script_loader_result_file.name + "?version=" + release
|
|
|
|
|
|
-bundle_items = sass_link.render() + js_script.render()
|
|
|
+bundle_items = (
|
|
|
+ sass_link.render() +
|
|
|
+ js_script.render() +
|
|
|
+ loading_screen.render()
|
|
|
+)
|
|
|
|
|
|
# Add bundle items tags
|
|
|
app_view_render.add("bundle_items", bundle_items)
|
|
|
@@ -212,7 +237,6 @@ compile(
|
|
|
"esbuild",
|
|
|
str(script_loader_file),
|
|
|
"--bundle",
|
|
|
- "--minify",
|
|
|
"--outfile=" + str(script_loader_result_file)
|
|
|
)
|
|
|
|
|
|
@@ -225,4 +249,12 @@ compile(
|
|
|
str(sass_loader_result_file)
|
|
|
)
|
|
|
|
|
|
+# Copy static folder
|
|
|
+compile(
|
|
|
+ "cp",
|
|
|
+ "-r",
|
|
|
+ str(static_files),
|
|
|
+ str(static_files_output)
|
|
|
+)
|
|
|
+
|
|
|
print("Build success!")
|