Skip to content

Commit 163f50e

Browse files
committed
wip: index file for web resources
1 parent f8d114e commit 163f50e

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

server/src/main/java/dev/harrel/App.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,22 @@ static void main() {
1212
.route("/*")
1313
.build();
1414
StaticContent webBundle =
15-
StaticContent.ofClassPath("/web/assets")
16-
.route("/assets")
15+
StaticContent.ofClassPath("/web")
16+
.route("/*")
17+
.directoryIndex("files.index")
1718
.preCompress()
18-
.putMimeTypeMapping("js", "application/javascript")
19-
.putMimeTypeMapping("css", "text/css")
20-
.putMimeTypeMapping("png", "image/png")
21-
.putMimeTypeMapping("ico", "image/x-icon")
2219
.putResponseHeader("Cache-Control", "max-age=86400")
2320
.build();
2421
StaticContent robots =
2522
StaticContent.ofClassPath("/robots/robots.txt")
2623
.route("/robots.txt")
24+
.putMimeTypeMapping("txt", "application/javascript")
2725
.build();
2826

2927
Jex.create()
30-
.plugin(webRoot)
31-
.plugin(webBundle)
3228
.plugin(robots)
29+
.plugin(webBundle)
30+
.plugin(webRoot)
3331
.jsonService(new Jackson3JsonService())
3432
.get("/api/version", new VersionHandler())
3533
.post("/api/json-validate", new ValidationHandler())

web/build.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ tasks.register('build', Exec) {
1717
exclude 'dist', 'node_modules', 'bun.lockb'
1818
}.findAll())
1919
outputs.dir('dist')
20+
21+
// create index file
22+
doLast {
23+
def fileNames = []
24+
def distPath = file('dist').toPath()
25+
fileTree('dist').each {
26+
fileNames.add distPath.relativize(it.toPath())
27+
}
28+
print fileNames
29+
def indexFile = distPath.resolve('files.index').toFile()
30+
indexFile.text = fileNames.join(System.lineSeparator())
31+
}
2032
}
2133

2234
artifacts {

0 commit comments

Comments
 (0)