BingZi233
05/17/2022, 11:31 PMPhil Richardson
05/18/2022, 8:33 AMstatic("assets")
combined with the nested resources("css")
exposes /assets/css
as the resource access path from which ollie.css
will be obtained.
What it is is actually saying is, when you want to access a resource under /assets
such as /assets/ollie.css
, search for ollie.css
inside of each of the following resources directories.
static/css
static/imgs
static/js
static/scss
static/vendors
Whereas your ollie.js
is in static/assets/css
It's worth looking at the specific example given in https://github.com/ktorio/ktor-documentation/tree/main/codeSnippets/snippets/static-resources
It provides a direct example of this config, including the files in their applicable resource directories.
If you want to update the config instead of restructuring your files, depends on how much freedom to access resources you want to permit.
If you must restrict so only content from the js
, css
, imgs
, scss
& vendors
(and sub-dirs of them) will be served, then you will need to split it out into more static()
calls.
Example
routing {
static("/") {
staticBasePackage = "static"
resource("index.html")
defaultResource("index.html")
static("assets/css") {
resources("assets/css")
}
static("assets/js") {
resources("assets/js")
}
}
}
If your ok to serve all directories and sub-dirs in static/assets
, including say fictional static/assets/other
that isn't specifically in the config right now, then you can retain much of your current config.
Example
routing {
static("/") {
staticBasePackage = "static"
resource("index.html")
defaultResource("index.html")
static("assets") {
staticBasePackage = "static/assets"
resources(".")
}
}
}
BingZi233
05/18/2022, 8:12 PM