Skip to content

Commit

Permalink
Add css to production bundle
Browse files Browse the repository at this point in the history
We could inline the CSS, but Vite requires a plugin, and I'd rather avoid the additional dependency
  • Loading branch information
jonathonherbert committed Mar 6, 2024
1 parent d44272e commit aa5b3ee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/controllers/V2App.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ class V2App(isDev: Boolean, val acl: Acl, dynamoClient: DynamoDbClient, val deps
val userDataTable = Table[UserData](config.faciatool.userDataTable)

val jsFileName = "dist/index.js"
val cssFileName = "dist/index.css"
val faviconDirectoryName = "favicon/"

val jsLocation: String = routes.V2Assets.at(jsFileName).toString
val cssLocation: String = routes.V2Assets.at(cssFileName).toString
val faviconLocation: String = routes.V2Assets.at(faviconDirectoryName).toString

val hasBreakingNews = acl.testUser(Permissions.BreakingNewsAlert, "facia-tool-allow-breaking-news-for-all")(req.user.email)
Expand Down Expand Up @@ -82,6 +84,7 @@ class V2App(isDev: Boolean, val acl: Acl, dynamoClient: DynamoDbClient, val deps
Ok(views.html.V2App.app(
"Fronts Tool",
jsLocation,
cssLocation,
faviconLocation,
Json.toJson(conf).toString(),
isDev
Expand Down
3 changes: 2 additions & 1 deletion app/views/V2App/app.scala.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@(title: String, jsLocation: String, faviconLocation: String, clientConfigJson:
@(title: String, jsLocation: String, cssLocation: String, faviconLocation: String, clientConfigJson:
String, isDev: Boolean)
<!DOCTYPE html>
<html lang="en">
Expand Down Expand Up @@ -49,6 +49,7 @@
<script type="module" src="http://localhost:5173/assets/fronts-client/@@vite/client"></script>
<script type="module" src="http://localhost:5173/assets/fronts-client/src/index.tsx"></script>
} else {
<link rel="stylesheet" href="@cssLocation">
<script type="module" src="@jsLocation" type="application/javascript"></script>
}
</body>
Expand Down

0 comments on commit aa5b3ee

Please sign in to comment.