Skip to content

Commit

Permalink
adaptive for other web frameworks
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethosa committed Dec 31, 2024
1 parent f8c922a commit 9a3663d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/happyx_native/app/app.nim
Original file line number Diff line number Diff line change
Expand Up @@ -256,29 +256,32 @@ template nativeAppImpl*(appDirectory: string = "/assets", port: int = 5123,
# Compile main
if cfgKind() == "HPX":
compileHpx(getScriptDir() / appDirectory)
else:
elif cfgKind() == "SPA":
echo staticExec(
"nim js -d:danger --opt:size --warnings:off --checks:off --assertions:off --stackTrace:off --lineTrace:off " & getScriptDir() / appDirectory / "main.nim"
)
when not defined(disableMinify):
optimizeJs(getProjectPath() / appDirectory / "main.js")
else:
discard
else:
when defined(buildAssets):
static:
if cfgKind() == "HPX":
compileHpx(getScriptDir() / appDirectory)
# Compile main
else:
elif cfgKind() == "SPA":
echo staticExec(
"nim js -d:danger --opt:size --warnings:off --checks:off --assertions:off --stackTrace:off --lineTrace:off " & getScriptDir() / appDirectory / "main.nim"
)
when not defined(disableMinify):
optimizeJs(getProjectPath() / appDirectory / "main.js")
else:
discard
else:
# Compile main
if cfgKind() == "HPX":
compileHpx(getCurrentDir() / appDirectory)
else:
elif cfgKind() == "SPA":
var data = execCmdEx(
"nim js -d:danger --opt:size " & getCurrentDir() / appDirectory / "main.nim"
)
Expand Down
4 changes: 2 additions & 2 deletions src/happyx_native/cli/build.nim
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ proc buildCommandAux*(target: string = OS, release: bool = false, opt: string =
rcedit(
none(string),
"build" / "app.exe",
{"icon": "assets" / "favicon.ico", "version": cfg.version}.toTable()
{"icon": cfg.appDirectory / "favicon.ico", "version": cfg.version}.toTable()
)
of "linux", "unix":
discard execCmd(fmt"nim c {mode} {opt} {browser} {assets} {app} --os:linux --outDir:build app.nim")
Expand Down Expand Up @@ -149,7 +149,7 @@ proc buildCommandAux*(target: string = OS, release: bool = false, opt: string =
removeDir("android" / "app" / "src" / "main" / "java")

# Build assets
mainActivity = mainActivity.replace("http://localhost:5123/", fmt"http://localhost:{cfg.port}/")
mainActivity = mainActivity.replace("http://localhost:15123/", fmt"http://localhost:{cfg.port}/")
var directoryTmp = "android" / "app" / "src" / "main" / "java"
for i in cfg.androidPackage.split("."):
directoryTmp = directoryTmp / i
Expand Down

0 comments on commit 9a3663d

Please sign in to comment.