Include a css file in a style tag in Elementary

I have a css file that I want to include in an Elementary style tag.

Right now, I'm doing it like this:

if let fileURL = Bundle.module.url(forResource: "theme", withExtension: "css"),
    let css = try? String(contentsOf: fileURL, encoding: .utf8) {
    style { HTMLRaw(css) }
}

I have to include the CSS file in my Package.swift so it can be referenced by the built code:

resources: [
    .process("Frontend/theme.css"),
],

I also have to copy the built .resources folder in my Dockerfile.

Seems like a lot of work just to reference a CSS file. Is there a better way to do this?

Copying into your container is pretty unavoidable, but you’d normally just copy a folder of resources etc. I don’t know the specifics of Elementary but you might be able to do something like Leaf and just copy in a file from a particular directory instead of using a SwiftPM resource

I agree with @0xTim about "just copy the files" - I want to question another thing though: Why would you want to "inline" your style sheet into the HTML?

Since you have a file anyway, just "link" to the file - this usually results in better loading behavior basically for free. Almost by definition style sheets are a lot more "static" than dynamically generated HTML, and boy do browsers like caching things ; )

I would just use some convention about where the assets are going to be and point your file middleware there (either using the bundle stuff or simply some configured folder)