purecss_react_nim.nimble 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Package
  2. import htmlgen
  3. version = "0.1.0"
  4. author = "Augusto Rivera"
  5. description = "A template to build websites using react.nim and purecss."
  6. license = "GPL-3.0"
  7. srcDir = "src"
  8. bin = @["purecss_react_nim"]
  9. # Dependencies
  10. requires "nim >= 1.0.0", "react >= 0.1.2", "jester >= 0.4.3"
  11. task clean, "Clean generated files.":
  12. if dirExists("public"):
  13. rmDir("public")
  14. rmFile("getassets")
  15. if fileExists(bin[0]):
  16. rmFile(bin[0])
  17. task getAssets, "Install frontend assets.":
  18. echo "Building index.html and getting external assets ..."
  19. let indexFile = "index.html"
  20. var indexHtml = "<!DOCTYPE html>"
  21. indexHtml.add(
  22. html(
  23. head(
  24. meta(charset="utf-8"),
  25. meta(name="viewport", content="width=device-width, initial-scale=1.0"),
  26. title("React, Nim, Pure.css Template"),
  27. link(rel="stylesheet", href="css/pure-min.css"),
  28. link(rel="stylesheet", href="css/marketing.css"),
  29. script(src="js/react.js"),
  30. script(src="js/react-dom.js"),
  31. script(src="js/app.js")
  32. ),
  33. body(onload="startApp()",
  34. `div`(id="root", class="container")
  35. )
  36. )
  37. )
  38. if not fileExists "getassets":
  39. exec "nimble c src/getassets.nim -d:ssl -o:./getassets"
  40. exec "./getassets"
  41. echo "Downloaded assets."
  42. withDir "public":
  43. if not fileExists(indexFile):
  44. writeFile(indexFile, indexHtml)
  45. task buildFrontend, "Build frontend files.":
  46. if not dirExists("public"):
  47. getAssetsTask()
  48. exec "nim js --o:public/js/app.js src/client/app.nim"