from pathlib import Path from json import loads from shutil import rmtree from shutil import copytree from source.cx_maketool import sass_compiler from source.cx_maketool import esbuild_compiler from source.cx_maketool import render from source.cx_maketool import script from source.cx_maketool import link root = Path(__file__).absolute() source = root / Path("source/") build = root / Path("build/") views = source / Path("views/") styles = source / Path("theme/") scripts = source / Path("scripts/") assets = source / Path("assets/") bundles = build / Path("bundle/") assets_output = build / Path("assets/") index = views / Path("core.html") scripts_loader = scripts / Path("code.js") theme_loader = styles / Path("core.sass") index_output = build / Path("index.html") script_bundle = bundle / Path("app.js") theme_bundle = bundle / Path("theme.css") if build.exists(): rmtree(build) build.mkdir() bundles.mkdir() sass_compiler(theme_loader).build(theme_bundle) esbuild_compiler(scripts_loader).build(script_bundle) copytree(assets, assets_output) copytree(config, config_output)