Skip to content

Commit 9a3663d

Browse files
committed
adaptive for other web frameworks
1 parent f8c922a commit 9a3663d

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/happyx_native/app/app.nim

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,29 +256,32 @@ template nativeAppImpl*(appDirectory: string = "/assets", port: int = 5123,
256256
# Compile main
257257
if cfgKind() == "HPX":
258258
compileHpx(getScriptDir() / appDirectory)
259-
else:
259+
elif cfgKind() == "SPA":
260260
echo staticExec(
261261
"nim js -d:danger --opt:size --warnings:off --checks:off --assertions:off --stackTrace:off --lineTrace:off " & getScriptDir() / appDirectory / "main.nim"
262262
)
263263
when not defined(disableMinify):
264264
optimizeJs(getProjectPath() / appDirectory / "main.js")
265+
else:
266+
discard
265267
else:
266268
when defined(buildAssets):
267269
static:
268270
if cfgKind() == "HPX":
269271
compileHpx(getScriptDir() / appDirectory)
270-
# Compile main
271-
else:
272+
elif cfgKind() == "SPA":
272273
echo staticExec(
273274
"nim js -d:danger --opt:size --warnings:off --checks:off --assertions:off --stackTrace:off --lineTrace:off " & getScriptDir() / appDirectory / "main.nim"
274275
)
275276
when not defined(disableMinify):
276277
optimizeJs(getProjectPath() / appDirectory / "main.js")
278+
else:
279+
discard
277280
else:
278281
# Compile main
279282
if cfgKind() == "HPX":
280283
compileHpx(getCurrentDir() / appDirectory)
281-
else:
284+
elif cfgKind() == "SPA":
282285
var data = execCmdEx(
283286
"nim js -d:danger --opt:size " & getCurrentDir() / appDirectory / "main.nim"
284287
)

src/happyx_native/cli/build.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ proc buildCommandAux*(target: string = OS, release: bool = false, opt: string =
9191
rcedit(
9292
none(string),
9393
"build" / "app.exe",
94-
{"icon": "assets" / "favicon.ico", "version": cfg.version}.toTable()
94+
{"icon": cfg.appDirectory / "favicon.ico", "version": cfg.version}.toTable()
9595
)
9696
of "linux", "unix":
9797
discard execCmd(fmt"nim c {mode} {opt} {browser} {assets} {app} --os:linux --outDir:build app.nim")
@@ -149,7 +149,7 @@ proc buildCommandAux*(target: string = OS, release: bool = false, opt: string =
149149
removeDir("android" / "app" / "src" / "main" / "java")
150150

151151
# Build assets
152-
mainActivity = mainActivity.replace("http://localhost:5123/", fmt"http://localhost:{cfg.port}/")
152+
mainActivity = mainActivity.replace("http://localhost:15123/", fmt"http://localhost:{cfg.port}/")
153153
var directoryTmp = "android" / "app" / "src" / "main" / "java"
154154
for i in cfg.androidPackage.split("."):
155155
directoryTmp = directoryTmp / i

0 commit comments

Comments
 (0)