| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 | #!/bin/pythonfrom pathlib import Pathfrom json import loadsfrom shutil import rmtreefrom shutil import copytreefrom maketool import sass_compilerfrom maketool import esbuild_compilerfrom maketool import renderfrom maketool import scriptfrom maketool import linkroot = Path(__file__).absolute().parentsource = root / Path("./")build = root / Path("build/")styles = source / Path("styles/")scripts = source / Path("scripts/")scripts_loader = scripts / Path("core.js")theme_loader = styles / Path("core.sass")full_bundle = scripts / Path("bundle.js")script_bundle = build / Path("pack.js")theme_bundle = build / Path("pack.css")bundle_tmp_output = build / Path("bundle.tmp.js")bundle_output = build / Path("bundle.js")if build.exists():    rmtree(build)build.mkdir()sass_compiler(theme_loader).build(theme_bundle)esbuild_compiler(scripts_loader).build(script_bundle)with theme_bundle.open() as style:    with script_bundle.open() as script:        script = script.read().replace("\"", "\\\"").replace("`", "\\`")        style = style.read().replace("\"", "\\\"").replace("`", "\\`")        rendering = render(full_bundle)        rendering.add("style", style)        rendering.add("script", script)                with bundle_tmp_output.open("w") as output:            output.write(rendering.finalize())esbuild_compiler(bundle_tmp_output).build(bundle_output)
 |