make-app.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/python
  2. from pathlib import Path
  3. from json import loads
  4. from shutil import rmtree
  5. from shutil import copytree
  6. from shutil import copy
  7. from maketool import sass_compiler
  8. from maketool import esbuild_compiler
  9. from maketool import render
  10. from maketool import script
  11. from maketool import link
  12. root = Path(__file__).absolute().parent
  13. source = root / Path("application/")
  14. build = root / Path("static/")
  15. views = source / Path("views/")
  16. styles = source / Path("theme/")
  17. scripts = source / Path("scripts/")
  18. assets = source / Path("assets/")
  19. bundle = build / Path("bundle/")
  20. assets_output = build / Path("assets/")
  21. scripts_loader = scripts / Path("core.js")
  22. theme_loader = styles / Path("core.sass")
  23. script_bundle = bundle / Path("app.js")
  24. theme_bundle = bundle / Path("theme.css")
  25. if build.exists():
  26. rmtree(build)
  27. build.mkdir()
  28. bundle.mkdir()
  29. sass_compiler(theme_loader).build(theme_bundle)
  30. esbuild_compiler(scripts_loader).build(script_bundle)
  31. copytree(assets, assets_output)
  32. for view in views.iterdir():
  33. if not view.is_file():
  34. continue
  35. if str(view.suffix) != ".html":
  36. continue
  37. copy(view, build / Path(view.name))