Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,28 @@ mvn_settings.xml
# Release folder
releases

# Frontend build assets
/hub/public

# Frontend node_modules
/frontend/node_modules

# Frontend Output
/frontend/.output
/frontend/.vercel
/frontend/.svelte-kit
/frontend/build

# Frontend OS
/frontend/.DS_Store
/frontend/Thumbs.db

# Frontend Env
/frontend/.env
/frontend/.env.*
!/frontend/.env.example
!/frontend/.env.test

# Frontend Vite
/frontend/vite.config.js.timestamp-*
/frontend/vite.config.ts.timestamp-*
38 changes: 37 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,39 @@ lazy val cloud_gcp = project
libraryDependencies ++= spark_all
)

// Webpack integration for frontend
lazy val buildFrontend = taskKey[Unit]("Build frontend")

lazy val frontend = (project in file("frontend"))
.settings(
buildFrontend := {
println("Installing frontend dependencies...")
import scala.sys.process._
val npmInstallResult = Process("npm install", file("frontend")).!

if (npmInstallResult != 0) {
sys.error("npm install failed!")
}

println("Building frontend...")
val buildResult = Process("npm run build", file("frontend")).!

if (buildResult == 0) {
println("Copying frontend assets to /hub/public...")
val buildDir = file("frontend/build")
val publicDir = file("hub/public")

// Clean the target directory if needed
IO.delete(publicDir)

// Copy the build files to the public folder
IO.copyDirectory(buildDir, publicDir)
} else {
sys.error("Frontend build failed!")
}
}
)

lazy val hub = (project in file("hub"))
.enablePlugins(PlayScala)
.settings(
Expand All @@ -186,7 +219,10 @@ lazy val hub = (project in file("hub"))
libraryDependencies ++= Seq(
guice,
"org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" % Test
)
),
// Ensure hub depends on frontend build
Compile / run := ((Compile / run) dependsOn (frontend / buildFrontend)).evaluated,
Compile / stage := ((Compile / stage) dependsOn (frontend / buildFrontend)).value
)

ThisBuild / assemblyMergeStrategy := {
Expand Down
1 change: 1 addition & 0 deletions frontend/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
4 changes: 4 additions & 0 deletions frontend/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Package Managers
package-lock.json
pnpm-lock.yaml
yarn.lock
8 changes: 8 additions & 0 deletions frontend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}
38 changes: 38 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# create-svelte

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).

## Creating a project

If you're seeing this, you've probably already done this step. Congrats!

```bash
# create a new project in the current directory
npm create svelte@latest

# create a new project in my-app
npm create svelte@latest my-app
```

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

## Building

To create a production version of your app:

```bash
npm run build
```

You can preview the production build with `npm run preview`.

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
33 changes: 33 additions & 0 deletions frontend/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import js from '@eslint/js';
import ts from 'typescript-eslint';
import svelte from 'eslint-plugin-svelte';
import prettier from 'eslint-config-prettier';
import globals from 'globals';

/** @type {import('eslint').Linter.Config[]} */
export default [
js.configs.recommended,
...ts.configs.recommended,
...svelte.configs['flat/recommended'],
prettier,
...svelte.configs['flat/prettier'],
{
languageOptions: {
globals: {
...globals.browser,
...globals.node
}
}
},
{
files: ['**/*.svelte'],
languageOptions: {
parserOptions: {
parser: ts.parser
}
}
},
{
ignores: ['build/', '.svelte-kit/', 'dist/']
}
];
Loading