Skip to content

Commit

Permalink
Merge pull request #29 from jvmusin/include-frontend
Browse files Browse the repository at this point in the history
Merge frontend project and setup build
  • Loading branch information
jvmusin authored Mar 18, 2024
2 parents bf954cb + c0ac852 commit 515fa0b
Show file tree
Hide file tree
Showing 49 changed files with 7,529 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/workflows/gradle-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ jobs:
with:
java-version: 21
distribution: 'temurin'
- name: Set up Node 21
uses: actions/setup-node@v4
with:
node-version: '21'
node-version-file: 'frontend/package-lock.json'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# syntax = docker/dockerfile:1.7

FROM eclipse-temurin:21.0.2_13-jdk-alpine
RUN apk add --update npm
COPY . .
RUN --mount=type=secret,id=application_yaml,dst=application.yaml cp application.yaml src/main/resources/application.yaml
RUN chmod +x gradlew && ./gradlew build
RUN chmod +x gradlew && ./gradlew -PbuildFrontend build

FROM eclipse-temurin:21.0.2_13-jre-alpine
COPY --from=0 /build/libs/polybacs-0.0.1-SNAPSHOT.jar app.jar
Expand Down
20 changes: 20 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,23 @@ tasks.withType<Test> {
exceptionFormat = TestExceptionFormat.FULL
}
}

if (project.hasProperty("buildFrontend")) {
val buildFrontend = tasks.register<Exec>("buildFrontend") {
group = "build"
description = "Builds the frontend."
commandLine = listOf("sh", "-c", "cd frontend && npm ci && npm run build")
dependsOn("compileKotlin")
}
val copyFrontend = tasks.register<Copy>("copyFrontend") {
group = "build"
description = "Copies the frontend build to the resources."
from("frontend/dist")
into("build/resources/main/static")
dependsOn(buildFrontend)
}
tasks.named<ProcessResources>("processResources") {
dependsOn(copyFrontend)
exclude("static/index.html")
}
}
19 changes: 19 additions & 0 deletions frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'prettier',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
24 changes: 24 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
Empty file added frontend/.prettierignore
Empty file.
7 changes: 7 additions & 0 deletions frontend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"singleQuote": true,
"semi": false,
"plugins": [
"prettier-plugin-tailwindcss"
]
}
30 changes: 30 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
export default {
// other rules...
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
}
```

- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
17 changes: 17 additions & 0 deletions frontend/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "src/index.css",
"baseColor": "neutral",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
13 changes: 13 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="https://rsms.me/inter/inter.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/app.tsx"></script>
</body>
</html>
Loading

0 comments on commit 515fa0b

Please sign in to comment.